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.
java.lang.String object I'm sure no other process will alter its contents.
Stringobjects are immutable how can we achieveString a = "Vehicle"; a = "New " + a;?