Difference between integer and int

Source: Internet
Author: User

Int is one of the eight primitive data types provided by Java. Java provides encapsulation classes for each original type, and integer is the Java-based int
Encapsulation class. The default value of int is 0, while the default value of integer is null. That is, integer can differentiate unassigned values from 0,
Int indicates that no value is assigned. For example, if you want to express the difference between not taking the test and 0, you can only use integer.
In JSP development, the default integer value is null. Therefore, when an El expression is used to display it in a text box, the value is a blank string, whereas int is the default value.
The default value is 0, so the result is 0 when the El expression is displayed in the text box. Therefore, int is not suitable for form data of the web layer.
Type.
In hibernate, if the oId is defined as an integer type, Hibernate can judge a type based on whether its value is null.
Objects are temporary. If the oId is defined as the int type, you also need to set its unsaved-value attribute in the HBM ing file.
0.
In addition, integer provides multiple integer-related operation methods. For example, to convert a string to an integer, integer also defines
A constant that represents the maximum and minimum values of an integer.

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.