核心Java字符串概念

时间:2014-10-02 06:53:44

标签: java

我想知道为什么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?
    }
}

0 个答案:

没有答案