public Class Example{
public static void main(String[] args) {
String s = new String("1");
s.intern();
String s2 = "1";
System.out.println(s == s2);
String s3 = new String("1") + new String("1");
s3.intern();
String s4 = "11";
System.out.println(s3 == s4);
}
}
这段代码的我机器上输出结果是 false false.但我看到原文 https://tech.meituan.com/2014/03/06/in-depth-understanding-string-intern.html 的结果是 false true.所以到底结果应该是什么? |
|