Java Integer parseUnsignedInt() method

tutorial and example
tutorial and example

The parseUnsignedInt() method of Java Integer class parses the string argument as an unsigned decimal integer.

The second parameter parses the string argument as an unsigned integer in the radix specified by the second argument.

The third parameter parses the CharSequence argument as an unsigned as a signed int in the specified radix, beginning at the specified beginIndex and extending to endIndex -1.

Syntax

  1. public static int parseUnsignedInt (String s) throws NumberFormatException
  2. public static int parseUnsignedInt (String s, int radix) throws NumberFormatException
  3. public static int parseUnsignedInt (CharSequence s, int beginIndex, int endIndex, int radix) throws NumberFormatException

Parameters

s-  a String containing the unsigned int representation to be parsed.

radix– the radix to be used while parsing s

beginIndex- the beginning index

endIndex- the ending index

 Return Value

This method returns an unsigned integer value represented by the argument in decimal or in the specified radix.

Throws

This method throws:

NumberFormatException- if the String is null.

IndexOutOfBoundsException- if beginIndex is negative, or if beginIndex is greater than endIndex or if endIndex is greater than s.length().

NumberFormatException- if the CharSequence does not contain a parsable unsigned int in the specified radix, or if radix is either smaller than Character.MAX_RADIX or larger than Character.MAX_RADIX.

Example 1

Output

Example 2

Output

Example 3

Output

Example 4

Output