Converting Int to a String in Java
Forums:
int number = 42;
String s1 = Integer.toString(number);
//s1 is "42"
String s2 = String.valueOf(number);
//s2 id "42"
String s3 = "" + number;
//s2 id "42"
String s4 = String.format("%03d", number);
//s1 is "042"
- Log in to post comments