Why String is immutable in Java?

Reading time: 10 minutes | Coding time: 5 minutes


An immutable object is an object whose internal state remains constant after it has been entirely created.This means that the public API of an immutable object guarantees us that its behaviour will remain same and will not change during its whole lifetime.


In Java, Strings are immutable which means that the existing String objects can't be changed i.e we can't modify the existing String objects or we can't change the internal state of the String...

 •  0 comments  •  flag
Share on Twitter
Published on July 20, 2020 22:57
No comments have been added yet.