Java NavigableMap.higherKey(K key)

Syntax

NavigableMap.higherKey(K key) has the following syntax.

K higherKey(K key)

Example

In the following code shows how to use NavigableMap.higherKey(K key) method.


import java.util.NavigableMap;
import java.util.TreeMap;
//from  w ww  .j a  v a  2s.c om
public class Main {
  public static void main(String args[]) {
    
    NavigableMap<String, String> nav = new TreeMap<String, String>();
    nav.put("A", "a");
    nav.put("B", "b");
    nav.put("C", "c");
    nav.put("D", "d");
    nav.put("E", "e");
    nav.put("F", "f");
    System.out.println(nav);
    System.out.println(nav.higherKey("G"));
  }
}


  

The code above generates the following result.