将一个List集合[["8",43],["9",52]],"8"和"9"是对应字段"ATMONTH",43和52是对应字段"VC"。现在想准确的抓取其中的字段但是一直报错:Ljava.lang.Object; cannot be cast to java.util.Map。提示类型转化错误。
for (int i=0;i<list.size();i++) {
Map map=(Map) list.get(i);
String atmonth=(String) map.get("ATMONTH");
String vc=(String)map.get("VC");
int tempmonth=Integer.parseInt(atmonth);
int vcount=Integer.parseInt(vc);}
后来用另外一种方式进行转化,放弃了MAP.get(“XX”)的方式获取值,而是采用Object[]数组的方式进行获值,其中的Object[0]是对用字段"ATMONTH",Object[1]是对用字段"VC",
for (int i=0;i<list.size();i++) {
Object[] object=(Object[]) list.get(i);
String atmonth=(String) object[0];
System.out.println(atmonth);
BigDecimal vc=(BigDecimal) object[1];
int tempmonth=Integer.parseInt(atmonth);
int vcount=vc.intValue();}