java 练习自动拆箱 装箱
Integer a = 1; Integer b = 2; Integer c = 3; Integer d = 3; Integer e = 321; Integer f = 321; Long g = 3L; Long h = 2L; Long bad= null; //true System.out.println(c==d); // false System.out.println(e==f); // true System.out.println(c==(a+b)); //true System.out.println(c.equals(a+b)); // true 计算自动拆箱 有一部分原始类型就会带坏其他对象 System.out.println(g==(a+b)); //false System.out.println(g.equals(a+b)); //true System.out.println(g.equals(a+h)); //int 自动转换为 long System.out.println(Integer.MAX_VALUE<Long.MAX_VALUE); // true System.out.println(g==3); //这个会报错 System.out.println(bad==3);