English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
To convert an int value to a String, please usetoString()
The following two ways use the method.
public class Demo { public static void main(String args[]) { int val = 10; String str = Integer.toString(val); System.out.println("String: "+str); } }
Output Result
String: 10
Let's look at another example.
public class Demo { public static void main(String args[]) { int val = 5; String str = new Integer(val).toString(); System.out.println("String: "+str); } }
Output Result
String: 5