Integer.parseInt (String s, int radix) Method

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/Miaoshuowen/article/details/101566304

parseInt(String s, int radix)

parseInt
public static int parseInt(String s,
                           int radix)
                    throws NumberFormatException

Using the radix specified by the second argument, the string parameter interpreted as a signed integer. In addition to the first character may be used to represent ASCII negative value minus sign '-' ( '\ u002D' ) , the characters in the string must radix numbers are designated (whether by Character.digit (char, int) It returns a negative value is determined). Returns an integer value obtained.
If any of the following occurs, it throws an exception of type NumberFormatException:

The first parameter is null or a zero-length string.
Character.MIN_RADIX cardinality is less than or greater than Character.MAX_RADIX.
If more than one length of the string, then in addition to the first character may be a minus sign '-' ( 'u002D'), but not any character represented by a digital radix specified string is present.
Int type value is not a string.
Example:

parseInt ( "0", 10) returns 0
the parseInt ( "473", 10) returns 473
the parseInt ( "- 0", 10) returns 0
the parseInt ( "- the FF", 16) returns -255
the parseInt ( "1.10011 million", 2 ) returns 102
the parseInt ( "2147483647", 10) returns 2147483647
the parseInt ( "- 2147483648", 10) returns -2147483648
the parseInt ( "2147483648", 10) throws a NumberFormatException
the parseInt ( "99",. 8) throws a NumberFormatException
the parseInt ( " Kona ", 10) throws NumberFormatException
parseInt (" the Kona ", 27) returns 411 787

Parameters:
S - contains an integer to be parsed representation String
the radix - base used in resolving s.
Returns:
string argument specifies an integer representation radix.
Throws:
NumberFormatException - int If the String does not contain a resolvable.

parseInt(String s)

public static int parseInt(String s)
                    throws NumberFormatException

Parse the string argument as a signed decimal integer. In addition to the first character may be used to represent ASCII negative value minus sign '-' ( '\ u002D'), the characters in the string must be a decimal number. Returns an integer value obtained, if the base 10 and the parameters given as arguments parseInt (java.lang.String, int) method of the same.

Parameters:
S - contains the parsed int representation of String.
Returns:
integer value represented by the argument in decimal.
Throws:
NumberFormatException - Integer If the string does not contain a parsable

Guess you like

Origin blog.csdn.net/Miaoshuowen/article/details/101566304