Here you can find the source of filterPrefix( SortedMap
private static <V> SortedMap<String, V> filterPrefix( SortedMap<String, V> baseMap, String prefix)
//package com.java2s; //License from project: Open Source License import java.util.SortedMap; public class Main { private static <V> SortedMap<String, V> filterPrefix( SortedMap<String, V> baseMap, String prefix) { if (prefix.length() > 0) { char nextLetter = (char) (prefix.charAt(prefix.length() - 1) + 1); String end = prefix.substring(0, prefix.length() - 1) + nextLetter;// ww w. jav a2s. c om return baseMap.subMap(prefix, end); } return baseMap; } }