arrayList add方法只是引用对象地址
List<Map<Stirng,Object>> list = new ArrayList(); Map<String, Object> map = new HashMap<>(); map.put("counter_id", "1"); map.put("pay_no", "000"); map.put("pay_name", "现金"); map.put("amount", "30"); list.add(map);//添加map map.clear()//将map清空 System.out.println(list); //输出 [{}]
List<Map<String, Object>> list = new ArrayList<>(); Map<String, Object> map = new HashMap<>(); map.put("counter_id", "1"); map.put("pay_no", "000"); map.put("pay_name", "现金"); map.put("amount", "30"); Map<String,Object> n = new HashMap<>(); n.putAll(tableMap); list .add(n); map.clear(); System.out.println(list); //输出 [{amount=30, pay_name=现金, pay_no=000, counter_id=1}]