Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.Collection; import java.util.HashMap; import java.util.Map; public class Main { public static <K, V> Map<K, V> subMap(Map<K, V> map, Collection<K> subKeys) { Map<K, V> newMap = new HashMap<K, V>(); for (K k : subKeys) { if (map.containsKey(k)) newMap.put(k, map.get(k)); } return newMap; } }