Get higher key from NavigableMap : NavigableMap « JDK 6 « Java






Get higher key from NavigableMap

 

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 higher after Sunday: %s%n", nav.higherKey("Sunday"));
  }
}

        








Related examples in the same category

1.NavigableMap Demo
2.Create NavigableMap from TreeMap
3.Get first key and first entry from NavigableMap
4.Get last key and last entry from NavigableMap
5.Get navigable key set from NavigableMap
6.Get floor key from NavigableMap
7.Get lower key from NavigableMap
8.Get ceiling key from NavigableMap
9.The NavigableMap Interface