+1 vote
in JAVA by
Why are the objects immutable in java?

1 Answer

0 votes
by

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

0 votes
0 votes
asked May 3, 2021 in JAVA by Robindeniel
0 votes
asked May 5, 2021 in JAVA by SakshiSharma
...