public class Company {
public static void main(String[] args) {
// 示例, 支持0.2开头
String currentVoltage = "20.014";
// 转换双精度
int totalFee1 = (int) (Double.parseDouble(currentVoltage));
// 转换单精度, 有时会使数据值变小;
int totalFee2 = (int) (Float.parseFloat(currentVoltage));
// 输出 20 20
System.out.println("totalFee1:" + totalFee1 + ",totalFee2:" + totalFee2 + ".");
}
}
原文:https://www.cnblogs.com/Twittery/p/14421920.html