Get lower key from NavigableMap : NavigableMap « Collections « Java Tutorial






import java.util.Calendar;
import java.util.Locale;
import java.util.Map;
import java.util.NavigableMap;
import java.util.TreeMap;

public class NavigableMapSample {
  public static void main(String args[]) {
    Calendar now = Calendar.getInstance();
    Locale locale = Locale.getDefault();

    Map<String, Integer> names = now.getDisplayNames(Calendar.DAY_OF_WEEK, Calendar.LONG, locale);
    NavigableMap<String, Integer> nav = new TreeMap<String, Integer>(names);
    System.out.printf("Whole list:%n%s%n", nav);
    System.out.printf("Key lower before Sunday: %s%n", nav.lowerKey("Sunday"));
  }
}








9.30.NavigableMap
9.30.1.The NavigableMap Interface
9.30.2.NavigableMap Demo
9.30.3.Create NavigableMap from TreeMap
9.30.4.Get first key and first entry from NavigableMap
9.30.5.Get last key and last entry from NavigableMap
9.30.6.Get navigable key set from NavigableMap
9.30.7.Get floor key from NavigableMap
9.30.8.Get lower key from NavigableMap
9.30.9.Get ceiling key from NavigableMap
9.30.10.Get higher key from NavigableMap