Map<String, Object> map = null;
List<BaseBean> beanlist = new ArrayList<BaseBean>();
for(int i=0;i<list.size();i++){
map = list.get(i);
basebean = new BaseBean();
basebean.setOrder_seq(map.get("ZBORDERID")+"");
basebean.setSequen((map.get("TEAMORDERID")+""));
basebean.setPassName((map.get("PASSNAME")+""));
basebean.setCardNO((map.get("DOCNUMBER")+""));
beanlist.add(basebean);
}
arraylist.add(basebean) 增加的是basebean对象的内存地址,如果for循环中,每次不重新产生新对象【basebean = new BaseBean();】,那么每次添加的都是同一个basebean对象,arraylist会以最后一次的内存地址为准!结果如下:
BaseBean [sequen=325690, order_seq=392240, passName=ODS/Thor, cardNO=G666666]
BaseBean [sequen=325690, order_seq=392240, passName=ODS/Thor, cardNO=G666666]
BaseBean [sequen=325690, order_seq=392240, passName=ODS/Thor, cardNO=G666666]
BaseBean [sequen=325690, order_seq=392240, passName=ODS/Thor, cardNO=G666666]
BaseBean [sequen=325690, order_seq=392240, passName=ODS/Thor, cardNO=G666666]
BaseBean [sequen=325690, order_seq=392240, passName=ODS/Thor, cardNO=G666666]