English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Per interpretare un numero e impostarlo in formato decimale, provare il seguente codice.
public class Demo { public static void main(String args[]) { int val = Integer.parseInt("5"); String str = Integer.toString(val); System.out.println(str); } }
Risultato di output
5
Nel programma sopra, abbiamo utilizzato i metodi Integer.parseInt() e Integer.toString() per convertire i numeri in decimale.
int val = Integer.parseInt("5"); String str = Integer.toString(val);
toString()
Il metodo sopra descritto rappresenta un valore come stringa e formato.