日期:2014-05-20 浏览次数:20840 次
public static void main(String[] args) { List list = new ArrayList(); List list1 = new ArrayList(); Map map = new HashMap(); for(Object o : list) { Map temp = (Map) o; map.put(temp.get("id"), temp); } for(Object o : list1) { Map temp = (Map) o; Map m = (Map)map.get(temp.get("id")); if(m != null) {//存在相同id List nameList = (List)m.get("list"); List tempList = (List) temp.get("list"); for(Object name : tempList) { if(!nameList.contains(name)) { nameList.add(name); } } } else {//不存在相同id map.put(temp.get("id"), temp); } } }
------解决方案--------------------
重写你的成员变量的方法