Java examples for Collection Framework:TreeMap
Get Sub Map from TreeMap
import java.util.TreeMap; import java.util.SortedMap; public class Main { public static void main(String[] args) { TreeMap treeMap = new TreeMap(); /*ww w . j av a2 s.co m*/ treeMap.put("1","One"); treeMap.put("3","Three"); treeMap.put("2","Two"); treeMap.put("5","Five"); treeMap.put("4","Four"); SortedMap sortedMap = treeMap.subMap("2","5"); System.out.println("SortedMap Contains : " + sortedMap); } }