There is a different ways to convert int to string in java. Java allows you to convert values from one datatype to another datatype. You can convert a string variable to numeric value and numeric value to string variable. In this article, we will see how to convert int to string in java.
Below are the different ways to convert int to string in Java:
- Integer.toString()
- String.valueOf()
- String.format()
- StringBuffer and StringBuilder
How to Convert int to String in Java?
1. Integer.toString()
The Integer.toString() method convert int to string. The toString() is static method of Integer class. The syntax of toString() method is given below:
public static String toString(int i)
Example:

2. String.valueOf()
The String.valueOf() method converts int to String. The valueOf() is the static method of String class. The syntax of valueOf() method is given below:
public static String valueOf(int i)
Example:

3. String.format()
The String.format() method is used to format given arguments into String. It is introduced since Jdk 1.5. The syntax of String.format() method is given below:
public static String format(String format, Object… args)
Example:

4. StringBuffer and StringBuilder
StringBuilder and StringBuffer classes are used to combine multiple values into a single string. StringBuffer is thread safe but slow, while StringBuilder is not thread safe but fast. Below I have provided an example.
Example:
