Integer与Double类型转换
时间:2021-02-20 17:58:18
收藏:0
阅读:348
示例代码
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
评论(0)