Java-Common Method Summary __java

Source: Internet
Author: User
1. Java.lang class Integer

Method: public static int parseint(String s)

Description: Parses the string argument as a signed decimal integer. The characters in a string must be decimal digits except that the first character can be used to represent a negative ASCII minus '-' (' \u002d '). Returns the resulting integer value as if the argument and cardinality 10 were given the public static int parseint (java.lang.String, int) method as a parameter.

Parameter: S-String that contains the int representation to resolve.

Returns the integer value represented by a decimal parameter.

Method: public static int parseint(String s, int radix)
Throws NumberFormatException

Description: Resolves a string parameter to a signed integer using the cardinality specified by the second parameter. Except that the first character can be used to represent a negative ASCII minus '-' (' \u002d '), the characters in the string must all be numbers of the specified cardinality. Returns the resulting integer value.

If any of the following occurs, a NumberFormatException type exception is thrown: The first argument is null or a string of zero length. Cardinality is less than Character.min_radix or greater than Character.max_radix. If the string is longer than 1, then there is any character in the string that is not represented by a number in the specified cardinality, except that the first character can be a minus sign '-' (' u002d '). The value represented by a string is not a value of type int.

Parameter: S-a String that contains the integer representation to parse; radix-the cardinality used when parsing s

Returns: An integer represented by a string parameter of the specified cardinality.

Example:

parseint ("0", 10)//Return 0
parseint ("473", 10)//Return 473
parseint ("-0", 10)//Return 0
parseint ("-ff", 16)//Return -255< C3/>parseint ("1100110", 2)//Return 102
parseint ("2147483647", 10)//Return 2147483647
parseint ("-2147483648", 10)// return -2147483648
parseint ("2147483648", 10)//Throw numberformatexception
parseint ("99", 8)//Throw NumberFormatException
parseint ("Kona", 10)//Throw numberformatexception
parseint ("Kona", 27)//Return 411787

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.