Wednesday, 18 September 2013

Immutable string in java

Immutable string in java

i have basic confusion .
String s2=new String("immutable");
System.out.println(s2.replace("able","ability"));
s2.replace("able", "abled");
System.out.println(s2);
In first print statement it is printing immutability but it is immutable
right? why so? and in next printing statement it is not replaced> any
answers welcome..

No comments:

Post a Comment