我想知道为什么s==a
评估为 true 但s==b
评估为 false 。
public class HelloTest {
public static void main(String[] args) {
String s = "Hello World";
final String a1 = "Hello ";
String a = a1 + "World";
String b2 = "Hello ";
String b = b2 + "World";
System.out.println(s == a); // true
System.out.println(s == b); // false why?
}
}