class="java" name="code"> package 测试; public class TestDemo { private static String getA() {return "a";} public static void test() { String a = "a"; String b = a + "b"; String c = "ab"; String d = new String(b); System.out.println(b == c); System.out.println(c == d); System.out.println(c == d.intern());//intern()方法用以手工入池. System.out.println(b.intern() == d.intern()); } public static void main(String[] args) { test(); } }