L04-String-class1 - ICS102 Lecture 4: String Class King...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ICS102 Lecture 4: String Class King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science Department December 6, 2010 ICS102: The class String 2 Outline The String Class Explicit String Objects String variables are References String Methods Escape Sequences December 6, 2010 ICS102: The class String 3 The String Class There is no primitive type for strings in Java The class (type) String is a predefined class in Java that is used to store and process strings A String object is a sequence of characters that is treated as a single value. When any (quote) appears, a String object is created automatically. A variable of type String can be given the value of a String object Explicit String Objects A declaration and object creation are needed for instances of the String class. For example, We normally use shorthand notation (only for Strings): String name1; name1 = new String ( "Salam" ); String name1; name1 = "Salam" ; These two statements are equivalent. December 6, 2010 4 ICS102: The class String String variables are References Code State of Memory String word1, word2; word1 = new String ( "Java" ); word2 = word1; A Both word1 and word2 are allocated memory (to store references), but the objects themselves are not yet created, so they both contain null....
View Full Document

This note was uploaded on 12/05/2010 for the course ICS 102 taught by Professor Zaman during the Fall '08 term at King Fahd University of Petroleum & Minerals.

Page1 / 19

L04-String-class1 - ICS102 Lecture 4: String Class King...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online