获取到的Map<String, String>集合是 BigDecimal类型的值,如果直接转换为String类型则报错:java.math.BigDecimal cannot be cast to java.lang.String
解决方法:先用Object类型接收,然后再转换成自己想要的类型
Map<String, String> m = list.get(i);
Object obj = m.get("OILAMOUNT");
String s = (String)m.get("OILAMOUNT"); //转String
float f = Float.valueOf(obj.toString()); //转float
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/19182.html