This code prints "B". Shouldn't it print nothing? I have read that concatenation (+) is like executing a method and therefore it results with new String but here it is not the case. I thought that maybe that's because def variable is final but compound operator with def variable does not work the same way...
String abcdef = "abcdef";
final String def = "def";
String a = "abc";
a += def;
String b = "abc" + def;
String c = "abc";
c = c + def;
if(abcdef == a) {
System.out.println("A");
}
if(abcdef == b) {
System.out.println("B");
}
if(abcdef == c) {
System.out.println("C");
}