0
Explain that
why is the answer RUNTIME EXCEPTION? int value = Integer.parse("12.7");
6 Answers
+ 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!