Java tutorial
import java.util.SortedMap; import java.util.TreeMap; public class Main { public static void main(String[] args) { SortedMap<String, String> sMap = new TreeMap<>(); sMap.put("CSS", "style"); sMap.put("HTML", "mark up"); sMap.put("Oracle", "database"); sMap.put("XML", "data"); SortedMap<String, String> subMap = sMap.subMap("CSS", "XML"); System.out.println(subMap); // Get the first and last keys String firstKey = sMap.firstKey(); String lastKey = sMap.lastKey(); System.out.println("First Key: " + firstKey); System.out.println("Last key: " + lastKey); } }