in java, i have created 2 string literals having same value
String a = "Hello";
String b = "Hello";
now both of them should have same reference
System.out.println(a==n); // returns true
but when i do
b+=" World";
System.out.println(a==b); // returns false
Now i have 2 questions here
1. why a and b are not referencing to same object after 'b+=' operation?
2. how come i'm able to change string b without any error?(because i have read String class is immutable)