Here you can find the source of subMap(Map
public static <K, V> Map<K, V> subMap(Map<K, V> map, Collection<K> keys)
//package com.java2s; import java.util.*; public class Main { public static <K, V> Map<K, V> subMap(Map<K, V> map, Collection<K> keys) { Map<K, V> subMap = new HashMap<K, V>(keys.size()); for (K key : keys) { V value = map.get(key);/*from w w w.j a v a 2 s. c o m*/ if (value != null) { subMap.put(key, value); } } return subMap; } }