String==汇总(jdk1.7及以上版本)
点击这里直接通往测试代码地址
String s1 = "abc";
String s2 = new String("abc");
String s1 = new String("ab") + new String("c");
String s1 = new String("ab") + new String("c");
s1.intern();
String s2="abc";
System.out.println(s1==s2);
String s1 = new String("ab") + new String("c");
String s2="abc";
s1.intern();
System.out.println(s1==s2);
String s1 = "a" + "b";
final String s1 = "a";
final String s2 = "b";
String s3 = s1 + s2;
String s4 = "ab";
System.out.println(s3 == s4);
String s1 = "a";
String s2 = "b";
String s3 = "ab";
String s4 = "ab";
System.out.println(s3 == s4);