Home > DeveloperSection > Interviews > Why string objects are immutable in java?

Posted on    April-25-2015 12:11 AM

 Java Java  String 
Ratings:
 1 Answer(s)
  373  View(s)
Rate this:

Mayank Tripathi
Mayank Tripathi

Total Post:807

Points:4035
Posted on    April-25-2015 12:11 AM

Because java uses the concept of string literal. Suppose there are 5 reference variables,all referes to one object "sachin".If one reference variable changes the value of the object, it will be affected to all the reference variables. That is why string objects are immutable in java.

Don't want to miss updates? Please click the below button!

Follow MindStick