String nombre_str = "22";Runtime:
int number = Integer.parseInt(nombre_str);
System.out.println(number);
22
String nombre_s="22";Execution
int number = Integer.valueOf(nombre_s);
System.out.println(number);
22
String nombre_s="9Ab";Output:
int number = Integer.parseInt(nombre_s);
System.out.println(number);
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.