+1 vote
in JAVA by (19.8k points)
Why are the objects immutable in java?

1 Answer

0 votes
by (19.8k points)

Because Java uses the concept of the string literal. Suppose there are five 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.

Related questions

+2 votes