String nombre_str = "22";Exécution:
int nombre = Integer.parseInt(nombre_str);
System.out.println(nombre);
22
String nombre_s = "22";Exécution
int nombre = Integer.valueOf(nombre_s);
System.out.println(nombre);
22
String nombre_s = "9Ab";En sortie:
int nombre = Integer.parseInt(nombre_s);
System.out.println(nombre);
Exception in thread "main" java.lang.NumberFormatException: For input string: "9Ab"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.valueOf(Unknown Source)
Please disable your ad blocker and refresh the window to use this website.