Java – Convert Integer to String

In Java, you can use String.valueOf() to convert an Integer to String.

1. String.valueOf

1.1 Example to convert an Integer or int 10 to a String.


	Integer num = 10;
	//int num = 10;
	
	String numInString = String.valueOf(num);

	System.out.println(numInString);

Output


10

2. toString()

It works on Integer object only.


	Integer num = 10;

	String numInString = num.toString();

	System.out.println(numInString);

Output


10

2.2 For primitive type int, try Integer.toString()


	int num = 10;

	String numInString = Integer.toString(num);

	System.out.println(numInString);

Output


10

References

mkyong

Founder of Mkyong.com, passionate Java and open-source technologies. If you enjoy my tutorials, consider making a donation to these charities.

0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments