How to convert an int to a string?

Question:
How to convert an int to a string?

Answer:
You can use these techniques:

Code:
public class Example {
   public static void main(String[] args) {
 
      int x = 12345;
 
      String str1 = "" + x;
      System.out.println(str1);
 
      String str2 = (new Integer(x)).toString();
      System.out.println(str2);
 
      String str3 = Integer.toString(x);
      System.out.println(str3);
 
      String str4 = String.valueOf(x);
      System.out.println(str4);
 
   }
}
 

Output:
$ java Example
12345
12345
12345
12345