Here is a very simple code:
public class Test2 {
public static void main(String[] args) {
String a = "hello2";
final String b = "hello";
String d = "hello";
String c = b + 2;
String e = d + 2;
System.out.println((a));
System.out.println((c));
System.out.println((e));
System.out.println((a == c));
System.out.println((a == e));
}
}
And the output is:
hello2
hello2
hello2
true
false
Please tell me why the last one is 'false'??Thanks