Friday, April 11

String is immutable in java


Yes, it true that string is immutable in java which means that the String object doesn't change.
But that can't be true because we have seen many occasions in the program where the String variable is changed.

Yes its true, but we have our understanding of String a bit wrong here. Actually unlike C program, in Java, String is not a primitive variable but a special Class. So in our code  actually we are creating a String object for new character sequence.

For more understanding go to this link String can't be immutable in java

No comments:

Post a Comment