Java – Convert Integer to String
By:Roy.LiuLast updated:2019-08-11
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
From:一号门
COMMENTS