Java代码如下:
String s = "0.01";
int i = Integer.parseInt(s);
但是这会引发 NumberFormatException... 可能出了什么问题?
However this is throwing a NumberFormatException... What could be going wrong?
0.01 不是整数(整数),所以你当然不能把它解析为一.请改用 Double.parseDouble
或 Float.parseFloat
.
0.01 is not an integer (whole number), so you of course can't parse it as one. Use Double.parseDouble
or Float.parseFloat
instead.
这篇关于如何对十进制数执行 Integer.parseInt()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!