127 critical point of Java Basic Data Type Packing, 127 critical point of Packing
1 package wrapper. demo; 2 3 public class WrapperDemo 4 {5 6/** 7 * @ param args 8 */9 public static void main (String [] args) 10 {11 12 // automatically boxed after JDK1.5. If one byte is packed, the data will be shared and no new space will be reopened 13 Integer a = 127; 14 Integer B = 127; 15 System. out. println (a = B); // true16 System. out. println (. equals (B); // true17 18 Integer c = 128; 19 Integer d = 128; 20 System. out. println (c = d); // false 21 System. out. println (c. equals (d); // true22 23 Integer x = new Integer (127); 24 Integer y = new Integer (127); 25 System. out. println (x = y); // false, because = is the object address, two new, obviously the address is not the same 26 System. out. println (x. equals (y); // true, override the equals method, only compare whether the values are equal, obviously equal 27 28} 29 30}