I know this has been covered but I\'ve seen inconsistent arguments here on SO.
So if I have:
String a = \"apple2e\";
String b = \"apple2e\";
System.
'a' and 'b' are the same reference, the problem is you are not comparing a and b. You should expect
a==b? false
but you just get
false
This is because +
takes precedence over ==
so what you have is
System.out.println(("a==b? " + a) == b);
In the same way you would expect the following to print true.
System.out.println(1 + 2 == 3);
What you need is
System.out.println("a==b? " + (a == b));