1 PackageWrapper.demo;2 3 Public classWrapperdemo4 {5 6 /**7 * @paramargs8 */9 Public Static voidMain (string[] args)Ten { One A //after JDK1.5, automatic boxing, if the boxed is a byte, then the data will be shared, will not re-open new space -Integer A = 127; -Integer B = 127; theSystem.out.println (A = = B);//true -System.out.println (A.equals (b));//true - -Integer C = 128; +Integer d = 128; -System.out.println (c = = d);//false +System.out.println (C.equals (d));//true A atInteger x =NewInteger (127); -Integer y =NewInteger (127); -SYSTEM.OUT.PRINTLN (x = = y);//false, because = = is the comparison object address, two new, obviously the address is not the same -System.out.println (X.equals (y));//true, overriding the Equals method, only comparing the values for equality, apparently equal - - } in -}
Java basic data Type 127 critical point for boxing