public List getList(){
List list = new ArrayList();
Map map1 = new HashMap();
Map map2 = new HashMap();
Map map3 = new HashMap();
Map map4 = new HashMap();
map1.put("tid", "a");
map1.put("tablename", "上海");
list.add(map1);
map2.put("tid", "b");
map2.put("tablename", "北京");
list.add(map2);
map3.put("tid", "c");
map3.put("tablename", "天津");
list.add(map3);
map4.put("tid", "d");
map4.put("tablename", "深圳");
list.add(map4); return list;
}
这个list中 我想把map3中的“天津”改成“太原”,怎么改
List list = new ArrayList();
Map map1 = new HashMap();
Map map2 = new HashMap();
Map map3 = new HashMap();
Map map4 = new HashMap();
map1.put("tid", "a");
map1.put("tablename", "上海");
list.add(map1);
map2.put("tid", "b");
map2.put("tablename", "北京");
list.add(map2);
map3.put("tid", "c");
map3.put("tablename", "天津");
list.add(map3);
map4.put("tid", "d");
map4.put("tablename", "深圳");
list.add(map4); return list;
}
这个list中 我想把map3中的“天津”改成“太原”,怎么改
System.out.println(list);
map3.put("tablename", "太原");
System.out.println(list);
是从list中修改的
在遍历map、
然后替换、