Convert integer value to String in Java
static String valueOf(int b) method of String class can be used to convert a int value to String in Java.
For eg. when we pass a int value '999' to valueOf method, it returns a string value '999'.
Example 1
class ItoSTest{
public static void main(String args[]){
int i=777;
String itoSt=String.valueOf(i);
System.out.println(itoSt);
}
}
Output 1
777
Example 2
class ItoSTest{
public static void main(String args[]){
int w=222;
String itoSt=String.valueOf(w);
System.out.println(itoSt);
}
}
Output 2
222