July 02, 2018

java.lang.NumberFormatException: For input string

Exception in thread "main" java.lang.NumberFormatException: For input string: "100.0"

String s = "100.0";
Integer i = Integer.parseInt(s);
System.out.println(i);

Exception in thread "main" java.lang.NumberFormatException: For input string: "100.0"

Solution

String s = "100.0";
Double d = Double.parseDouble(s);
System.out.println(d.intValue());

No comments:

Post a Comment

Your feedback may help others !!!

Facebook comments