Integer.parseint () and integer.valueof ("str") in Java. Application of Intvalue () method

Source: Internet
Author: User
The parseint (String s) method is a static method of class integer, and its function is to convert the formal parameter s to integers, such as:
Interger.parseint ("1") =1;
Integer.parseint ("a") =20;
Integer.parseint ("324") =324;
Of course, the integers represented by s must be legitimate, or they would throw an exception.

valueof (String s) is also a static method of the integer class, which is to convert the formal parameter s to an integer object,
What is an integer object, and the integer is the basic data type int type wrapper class, is to wrap int into a class, which is necessary in many situations. If you do not understand, you think int is the mini version of the Integer, easy to use a lot, but also lost some features, OK, look at the code:
interger.valueof ("123") =integer (123)
The integer (123) is the object representation of integer 123, and it calls the Intvalue () method, which converts the object representation of 123 to the basic data 123

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.