The difference between int and integer in Java

Source: Internet
Author: User

To figure out the difference between int and integer, you need to figure out what the wrapper class is.

Although the Java language is a typical object-oriented programming language, the 8 basic data types do not support object-oriented programming mechanisms, and basic types of data do not have "object" attributes-no attributes, no methods to invoke. They are used only to cater to the deep-rooted habits of human beings and indeed to perform routine data processing in a simple and effective manner. This use of non-object-oriented technology can sometimes be inconvenient, such as reference type data inherit the attributes of the object class, to be converted to string type, as long as simply call the object class defined in the ToString (), and the basic data type is converted to string Type is much more troublesome. To solve this problem, the Java language introduces the concept of encapsulating classes, defining the appropriate reference types for each base data type in the JDK, and calling it a wrapper class (Wrapper Classes).

The following table describes the basic data types and their corresponding wrapper classes:

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.