有大佬知道,为什么在jdk1.8中,下面代码的结果为true、false、false、false吗?
String s1 = new StringBuilder().append("ja").append("va1").toString();
System.out.println(s1.intern() == s1);
String s2 = new StringBuilder().append("ja").append("va").toString();
System.out.println(s2.intern() == s2);
String s3 = new StringBuilder("java2").toString();
System.out.println(s3 == s3.intern());
String s4 = new StringBuilder().append("java3").toString();
System.out.println(s4 == s4.intern());
String s1 = new StringBuilder().append("ja").append("va1").toString();
System.out.println(s1.intern() == s1);
String s2 = new StringBuilder().append("ja").append("va").toString();
System.out.println(s2.intern() == s2);
String s3 = new StringBuilder("java2").toString();
System.out.println(s3 == s3.intern());
String s4 = new StringBuilder().append("java3").toString();
System.out.println(s4 == s4.intern());