Java NavigableMap get floor 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 w ww .ja v a 2 s. c o m*/ System.out.println(nav); System.out.println(nav.floorKey("3")); System.out.println(nav.floorKey("Not Exist")); } }