String object is immutable, Explain.

String object is immutable. Explain.

- This means, once you have created String object and assigned a value, you can't change the value of the object.

- If you try to change the value, a new object is created while the previous one is still there in the memory.

- The string object once created the data or state can't be changed but a new string object is created.

- The string objects in Java are immutable as it uses the concept of string literal.

- If one reference variable changes the value of the object, it will be affected to all the reference variables.
Difference between traditional java Array and Arraylist class
Difference between traditional java Array and Arraylist class - Traditional java array is fixed length whereas ArrayList supports dynamic arrays that can grow...
Difference between pass by value and pass by reference
Difference between pass by value and pass by reference - In pass by value, a copy of variable is passed to the method; the values of the variable can’t be changed in the method.....
What are access modifiers in JAVA?
What are access modifiers in JAVA?
Post your comment