What do you mean by string immutability in Java?

Ques:what is meant by strings are immutable in java?
Ans: immutable means that once an object of that Class has been created it can't be altered.

This is useful as it means you can pass references to the object around, without worrying that someone else is going to change it's contents.

Why String is immutable?
If they were mutable then there would be no String pool implementation and the performance gains of the String pool become lost.

People who read this post also read :



0 comments:

Post a Comment

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More