Java NavigableMap get lower key
import java.util.NavigableMap; import java.util.TreeMap; public class Main { public static void main(String args[]) { NavigableMap<String, Integer> nav = new TreeMap<String, Integer>(); nav.put("1", 1); nav.put("2", 2); nav.put("3", 3); nav.put("4", 4); nav.put("5", 5); //from www.ja v a2s. c o m System.out.println(nav); System.out.println(nav.lowerKey("3")); System.out.println(nav.lowerKey("Not Exist")); } }