81,092
社区成员
发帖
与我相关
我的任务
分享
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
public class Test {
public static void main(String[] args) {
// 使用String,Double对
Map<String, Double> map = new HashMap<String, Double>();
map.put("price", 45.0);
Double d = map.get("price");
if (d != null) {
double price = d.doubleValue();
System.out.println(price);
}
//使用String,BigDecimal对
Map<String, BigDecimal> map2 = new HashMap<String, BigDecimal>();
map2.put("price", new BigDecimal("45.0"));
BigDecimal decimal = map2.get("price");
if (decimal != null) {
double price = decimal.doubleValue();
System.out.println(price);
}
}
}