Survey of gradually mining autoboxing/auto-unboxing (1)

Source: Internet
Author: User

The last error in the original reference resource should be:

  • The Jakarta commons primitives component provides a set of container classes dedicated to saving basic types of data. Compared with using Java Collection framework and autoboxing/auto-unboxing to accomplish the same task, they have better performance.

Thanks to learner for correction.

The original "equivalent form after autoboxing" in Listing 4 is incorrect and should be:

Listing 4: equivalent form of collection Al = new arraylist () after autoboxing ();
Al. Add ( Integer. valueof (1));

During autoboxing, the constructor of the corresponding package class is not called directly, instead, use their valueof static method to obtain the new instance (the valueof method of the package classes in j2se 1.5 is enhanced, and the value of the corresponding basic type is acceptable ).

Correspondingly, the original "listing 11: autoboxing operations will happen before automatic upward transformation" should be changed:

Listing 11: The autoboxing operation will take place before the automatic upward transformation. Int I = 27828;
System. Out. println ( (Long) integer. valueof (I));/* Compilation Error */

In addition, the original "list 12: forced upward transformation is required first, and then boxing" has a written mistake, which should be changed:

Listing 12: You need to force upward transformation before making boxingint I = 27828;
System. Out. println (long) (Long)I );

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.