Main Tutorials

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

About Author

author image
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments