int and Integer;math.round (11.5) and Math.Round (-11.5)

Source: Internet
Author: User

int is one of the 8 raw data types provided by Java. Java provides encapsulation classes for each primitive type, and integer is the wrapper class provided by Java for Int. The default value for int is 0, and the default value for integer is null, that is, integer can differentiate between unassigned and value 0, and int cannot express an unassigned condition, for example, if you want to express the difference between not taking an exam and the test score of 0, you can only use integer. In JSP development, the default for integer is null, so when displayed in a text box with an El expression, the value is a blank string, and the default value of int defaults to 0, so when the El expression is displayed in the text box, the result is 0, so that int does not work as a type of form data for the Web tier.

In Hibernate, if the OID is defined as an integer type, hibernate can determine whether an object is temporary based on whether its value is null or not, and if the OID is defined for the int type, It is also necessary to set its Unsaved-value property to 0 in the HBM mapping file.

In addition, the integer provides multiple integer-related action methods, such as converting a string to an integer, and also defining constants that represent the maximum and minimum values of integers.

Math.Round (11.5) and Math.Round (-11.5)

The Math class provides three methods related to rounding: Ceil, floor, and round, which correspond to the meanings of their English names, for example, the English meaning of Ceil is the ceiling, the method represents an upward rounding, the result of Math.ceil (11.3) is 12, The result of Math.ceil (-11.3) is that the English meaning of -11;floor is the floor, the method is to take the rounding down, the result of Math.ceil (11.6) is the result of 11,math.ceil (-11.6) is-12; the most difficult thing to Master is the round method, It means "rounding", the algorithm is Math.floor (x+0.5), the original number is added 0.5 and then rounded down, so the result of Math.Round (11.5) is 12,math.round (-11.5) of the result is-11.

int and Integer;math.round (11.5) and Math.Round (-11.5)

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.