I'm new to java programming. And I don't understand why string objects are immutable in java.
String a = "Vehicle";
I'm new to java programming. And I don't understand why string objects are immutable in java.
String a = "Vehicle";
Because java uses the concept of string literal. Suppose there are five reference variables, all refers to one object "Vehicle"
.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.