日期:2014-05-20 浏览次数:21017 次
Map<String, String> mapA = new HashMap<String, String>(); Map<String, String> mapB = new HashMap<String, String>(); Map<String, String> mapAdd = new HashMap<String, String>(mapB); Map<String, String> mapDel = new HashMap<String, String>(); Map<String, String> mapChange = new HashMap<String, String>(); Map<String, String> mapUnChange = new HashMap<String, String>(); Iterator<String> it = mapA.keySet().iterator(); while(it.hasNext()) { String key = it.next(); String val = mapA.get(key); if(mapB.containsKey(key)) { String bVal = mapB.get(key); if(val != null && val.equals(bVal) || val == bVal) { mapUnChange.put(key, val); } else { mapChange.put(key, val); } mapAdd.remove(key); } else { mapDel.put(key, val); } } }
------解决方案--------------------