In java, string objects are immutable. Immutable simply means unmodifiable or unchangeable.
Once string object is created its data or state can’t be changed but a new string object is created.
Let’s try to understand the immutability concept by the example given below:
Why string objects are immutable in java?
Because java uses the concept of string literal. Suppose there are 5 reference variables, all refer to one object “Sachin”.If one reference variable changes the value of the object, it will be affected by all the reference variables. That is why string objects are immutable in java.