Sunday, May 6, 2018

how java string immutable?

I have a string in method in java class as below




public void show(){
String s1;
s1 = "abc";
s1 = "def";
System.out.println(s1);
}


Here the output is def, but as String is immutable so I don't understand how string s1 is immutable here as I can change the String s1 content from abc to def.




Could you please make me understand this?

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...