TreeMap navigableKeySet() method in java
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);
}
}
}