Integer toString() in Java (original) (raw)

Last Updated : 23 Jan, 2026

The java.lang.Integer.toString() method is an inbuilt method in Java used to convert an integer value into its corresponding String representation. The Integer class provides multiple overloaded versions of this method for different use cases.

1. Integer.toString()

This method returns a String object representing the value of the current Integer object.

Syntax

public String toString();

**Example: This example shows how to convert an Integer object into a String using the toString() method in Java.

Java `

public class GFG { public static void main(String[] args) { Integer num = 25;
String str = num.toString(); // Convert Integer to String System.out.println(str);
} }

`

**Explanation:

2. Integer.toString(int a)

This method returns a String representation of the specified integer value.

Syntax

public static String toString(int a);

**Example: This example demonstrates how to convert a primitive integer value into a string using the Integer.toString() method.

Java `

public class GFG{ public static void main(String[] args) { int a = -787;
String result = Integer.toString(a); // Convert int to String System.out.println(result);
} }

`

**Explanation:

3. Integer.toString(int a, int base)

This overloaded method returns a string representation of the integer a in the specified radix (base).If the base is less than Character.MIN_RADIX (2) or greater than Character.MAX_RADIX (36), base 10 is used by default.

Syntax

public static String toString(int a, int base);

**Example: This example demonstrates how to convert an integer value into a string using different number bases (radix).

Java `

public class GFG { public static void main(String[] args) { int binaryValue = 71; String binaryResult = Integer.toString(binaryValue, 2); System.out.println(binaryResult); // Output: 1000111

    int hexValue = 314;
    String hexResult = Integer.toString(hexValue, 16);
    System.out.println(hexResult); // Output: 13a
}

}

`

**Explanation: