Henry Wong wrote:
Nagashri Kadur wrote: public static void main(String[] args) {
String str1 = new String("This is a string");
str1 = "I thought this was immutable !! \n How \t did \t this \t happen ? ";
System.out.println("str1 = " + str1 );
}
The above mentioned code is compiling and is resulting in the following being displayed.
str1 = I thought this was immutable !!
How did this happen ?
If String is immutable how is this working ?
Can you tell us the difference between an object and a reference?
Henry