Java代码如下:
String s = "0.01";
int i = Integer.parseInt(s);
然而,这是抛出一个NumberFormatException...会出什么问题呢?
发布于 2009-09-20 13:16:16
0.01不是一个整数,所以你当然不能把它作为一个整数来解析。请改用Double.parseDouble
或Float.parseFloat
。
发布于 2009-09-20 13:56:40
使用,
String s="0.01";
int i= new Double(s).intValue();
发布于 2013-04-03 22:08:45
String s="0.01";
int i = Double.valueOf(s).intValue();
https://stackoverflow.com/questions/1450991
复制相似问题