The difference between int and integer in Java

Source: Internet
Author: User

The difference between an int and an integer is, in large terms, the difference between the basic data type and its wrapper class:

int is the basic type, the value is stored directly, and the integer is the object, pointing to the object with a reference

Data types in 1.Java are divided into basic data types and complex data types

int is the former and the integer is the latter (that is, a class), so the variables of the int class are initially 0 when the class is initialized. The integer variable is initialized to null.

2. When initializing:

int i =1;integer i= new Integer (1);(to look at Integer as a class); but because of the automatic packing and unpacking

Makes it possible to use the Integer class: integer i= 1;

int is the basic data type (the trace left for the process, but a useful addition to Java), an Integer is a class, an int extension, and a lot of conversion methods are defined.

Reference URL: http://www.cnblogs.com/shenliang123/archive/2011/10/27/2226903.html

The difference between int and integer in Java

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.