Just started to learn Java, and saw that both string and array are reference types. I don\'t understand the following issue:
String a = \"a1\";
String b
In the array case, you're actually modifying the array, and thus if one reference is changed, so is the other.
In the string case, you are not modifying the object, you are simply assigning a different object to that reference.
As you noted: a=b
means "let a point to the same object as b is pointing". Following the same line of thought, a="rrr"
means "let a point to the literal "rrr"", which has nothing to do with with b.