English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Per convertire un valore int in String, usaretoString()
Ecco come utilizzare entrambi i metodi.
public class Demo { public static void main(String args[]) { int val = 10; String str = Integer.toString(val); System.out.println("String: " + str); } }
Risultato di output
String: 10
Lasciate che guardiamo un altro esempio.
public class Demo { public static void main(String args[]) { int val = 5; String str = new Integer(val).toString(); System.out.println("String: " + str); } }
Risultato di output
String: 5