Java NavigableMap get ceiling key

Description

Java NavigableMap get ceiling key

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

public class Main {
  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);
    System.out.println(names);/*from www  .  j av  a 2s  .c  o  m*/
    
    
    NavigableMap<String, Integer> nav = new TreeMap<String, Integer>(names);
    System.out.println("NavigableMap:"+ nav);
    
    System.out.println("Key ceiling after Monday:"+ nav.ceilingKey("Monday"));
    

  }
}



PreviousNext

Related