What's the difference between int and integer in Java?

Source: Internet
Author: User










I.intvalue () to extract the value of I

Use occasions, such as saying
To ArrayList inside add, must add is an object
and int is not an object, it can only be added to the integer.

Almost everything you want to work with in Java is an object, and basic data types, such as defined variables such as int,double and the letter constants in your program, are not objects. An integer is wrapping an int base data type as an object, which is called boxing (autoboxing) in Java, for example:
Integer i = new Integer (10);
is to instantiate I as an object. The auto-boxing function is provided after Java5.0, as with the example above:
Integer i = 10;
Specific things still suggest you find detailed information to learn.

int i = 0;
Integer j = new Integer (0);
i = = J.intvalue () true;
In java1.4 and the previous version of the basic type int double is not directly placed in the list, map, etc., must be converted to an integer or double type to be



What's 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.