The toString() method of Java Integer class returns a String object which represents this Integer’s value.

The second syntax returns a String object which represents the specified integer.

The third syntax returns a string representation of the specified argument in the radix specified by the given radix.

Syntax

  • public String toString ()
  • public static String toString (int i)
  • public static String toString (int i, int radix) 

Parameters

The parameter ‘i’ represents an integer to be converted to a string and the parameter ‘radix’ represents the radix to use in the string representation.

Return Value

This method returns a String which represents the same value as this argument in base 10 or in the specified radix.

Example 1

Output

Example 2

Output

Example 3

Output

Example 4

Output

Pin It on Pinterest

Share This