Wednesday 18 November 2015

What is String in Java? Why String is immutable or final in Java

String : String is basically an object that represents sequence of char values. String objects are immutable means once we create string we are not allowed to perform any changes on that object, if we want to perform any changes with those changes a new string object will create.

String Objects are Immutable : Because java uses the concept of string literal.Suppose there are 5 reference variables,all refers to one object "GetSure".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 or final in java.

No comments:

Post a Comment