package 测试2; public class Test { public static void main(String[] args) { int i=0; Integer j = new Integer(0); System.out.println(i==j);//true System.out.println(j.equals(i));//true String a = "你好"; String str = new String("你好"); //str.intern();//入池必须在new的位置入才有效,否则还是false System.out.println(a==str);//false System.out.println(a.equals(str));//true //那么如何用"=="来实现两个字符串比较结果相等呢? String a1 = "hello"; String str1 = new String("hello").intern();//这样入池才有效 System.out.println(a1==str1);//结果是true } }