Java tutorial
//package com.java2s; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Map.Entry; public class Main { /** * retain the keyIdMap keys not in keyValueMap.keys() * * @param keyValueMap * @param keyIdMap * @return */ public static <G> List<G> retainKeysNotIn(Map<String, G> keyIdMap, Map<String, ?> keyValueMap) { List<G> result = new ArrayList<G>(); for (Entry<String, G> keyIdMapEntry : keyIdMap.entrySet()) { if (keyValueMap.get(keyIdMapEntry.getKey()) == null) { result.add(keyIdMapEntry.getValue()); } } return result; } }