Java NavigableMap get higher key

Description

Java NavigableMap get higher 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 w  w  .j a v  a 2  s  .  co m
    System.out.println(nav);
    
    System.out.println(nav.higherKey("3"));
    
    System.out.println(nav.higherKey("Not Exist"));
  }
}



PreviousNext

Related