Answers for "TreeMap navigableKeySet() method in java"

1

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);
      }
   }
}
Posted by: Guest on October-28-2020
1

TreeMap navigableKeySet() method in java

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);
      }
   }
}
Posted by: Guest on October-28-2020

Code answers related to "TreeMap navigableKeySet() method in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language