The valueOf() method of Java Integer class returns an Integer object holding the specified int value.

The second method returns an Integer object holding the specified String value.

The third syntax returns an Integer object which represents the specified String when parsed with the given radix.

Syntax

  1. public static Integer valueOf (int i)
  2. public static Integer valueOf(String s) throws NumberFormatException
  3. public static Integer valueOf(String s, int radix) throws NumberFormatException

 Parameters

i- an int value

s- the string to be parsed

radix- the radix to be used in interpreting s

Throws

The valueOf() method throws:

NumberFormatException- if the string does not contain a parsable int.

 Return Value

This method returns an int object holding the value represented by ‘i’ or by the string or by the string argument in the specified radix.

Example 1

Output

Example 2

Output

Example 3

Output

Example 4

Output

Pin It on Pinterest

Share This