String s = "" + i;
String s = String.valueOf(i);
String s = new Integer(i).toString();
// First Method
System.out.println(String.valueOf(12345));
// Second Method
System.out.println(Integer.toString(12345));
// Third Method
System.out.println(new Integer(12345).toString());
// Fourth Method
System.out.println(String.format("%d", 12345));
// Fifth Method
System.out.println(new StringBuffer().append(12345).toString());
// Six Method
System.out.println(new StringBuilder().append(12345).toString()); // Seventh Method
int num = 12345; String numString = "" + num; System.out.println(numString);
}
}
Output
12345
12345
12345
12345
12345
12345
12345