代码:
String s3= new StringBuilder("ni").append("hao").toString();
System.out.println(s3.intern() == s3);
String s1 = new StringBuilder("go").append("od").toString();
System.out.println(s1.intern() == s1);
String s2 = new StringBuilder("ja").append("va").toString();
System.out.println(s2.intern() == s2);
运行结果:
1.7
1.8