Java basic data Type 127 critical point for boxing

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.