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.


  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


i- an int value

s- the string to be parsed

radix- the radix to be used in interpreting s


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


Example 2


Example 3


Example 4


Pin It on Pinterest

Share This