0
Explain that
why is the answer RUNTIME EXCEPTION? int value = Integer.parse("12.7");
6 Respuestas
+ 1
If you want to parse an integer, you should use .parseInt method , moreover, in this case the string must be “12”, not “12.7”
For example:
int value = Integer.parseInt("12");
+ 1
12.7 is a double/float not an int
+ 1
Thats fine but if you try Integer.parse("12.7"); it will cause an error
0
Are you sure that I can't use 12.7 as a String???
0
I mean
String string = "12.7";
0
Got it, thanks!