How do I convert an integer variable to a string variable in Java?
There are at least three ways to do it. Two have already been pointed out:
String s = String.valueOf(i);
String s = Integer.toString(i);
Another more concise way is:
String s = "" + i;
See it working online: ideone
This is particularly useful if the reason you are converting the integer to a string is in order to concatenate it to another string, as it means you can omit the explicit conversion:
System.out.println("The value of i is: " + i);