"Java" Java wrapper class, Java Automatic Packaging (boxing) and unpacking (unpacking)

Source: Internet
Author: User
Packing class

Everything in Java is an object, so many operations are for objects, and Java will automatically wrap the usual data types into objects of the corresponding classes.
Support for automatic package and unpacking after jdk1.5

Wrapper classes for common data types

Packing

Boxing is the object that changes the base data type to the corresponding class.

listnew ArrayList();//list的各种操作都是针对对象的list.add(5);//5本来是int类型的,现在自动包装成了Integer类的对象
Unpacking

Unpacking is to change the object of the corresponding class into the appropriate basic data type

list.get(0)//得到第0个位置的对象,然后将它拆箱为基本的数据类型 也就是5

"Java" Java wrapper class, Java Automatic Packaging (boxing) and unpacking (unpacking)

Related Article

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.