|
String Objects
String objects are immutable - they cannot be changed once they have been created. References to string objects may be changed.
C and C++ programmers often wonder whether Java Strings are simply arrays
of characters. It is true that Java internally handles Strings as an array of
characters, but it is best if the programmer thinks of the String as an object
since the programmer can’t access the characters and change them.
Let's look at an example:
String str1 = new String ("I like dogs.");
String str2 = new String("I prefer cats.");
| |  |
|
 | |