Check out example codes for "TreeMap navigableKeySet() method in java". It will help you in understanding the concepts better.

Code Example 1

import java.util.NavigableSet;
import java.util.TreeMap;
public class TreeMapNavigableKeySetMethodExample
{
   public static void main(String[] args)
   {
      try
      {
         TreeMap<Integer, String> tm = new TreeMap<Integer, String>();
         tm.put(11, "apple");
         tm.put(12, "banana");
         tm.put(13, "grapes");
         tm.put(14, "orange");
         tm.put(15, "pineapple");
         System.out.println("Given TreeMap: " + tm);
         // get NavigableSet view of keys using navigableKeySet() method
         NavigableSet<Integer> ns = tm.navigableKeySet();
         System.out.println("Value is: " + ns);
      }
      catch(NullPointerException ex)
      {
         System.out.println("Exception: " + ex);
      }
   }
}

Code Example 2

import java.util.NavigableSet;
import java.util.TreeMap;
public class TreeMapNavigableKeySetMethodExample
{
   public static void main(String[] args)
   {
      try
      {
         TreeMap<String, Integer> tm = new TreeMap<String, Integer>();
         tm.put("apple", 11);
         tm.put("banana", 12);
         tm.put("grapes", 13);
         tm.put("orange", 14);
         tm.put("pineapple", 15);
         System.out.println("Given TreeMap: " + tm);
         // get NavigableSet view of keys using navigableKeySet() method
         NavigableSet<String> ns = tm.navigableKeySet();
         System.out.println("Value is: " + ns);
      }
      catch(NullPointerException ex)
      {
         System.out.println("Exception: " + ex);
      }
   }
}

Learn ReactJs, React Native from akashmittal.com