treemap floorkey 28 29 method in java

Solutions on MaxInterview for treemap floorkey 28 29 method in java by the best coders in the world

showing results for - "treemap floorkey 28 29 method in java"
Beatrice
17 Oct 2019
1import java.util.TreeMap;
2public class TreeMapFloorkeyExample
3{
4   public static void main(String[] args)
5   {
6      TreeMap<Integer, String> tm = new TreeMap<Integer, String>();
7      tm.put(60, "apple");
8      tm.put(10, "banana");
9      tm.put(50, "cherry");
10      tm.put(30, "fig");
11      tm.put(80, "grape");
12      tm.put(90, "kiwifruit");
13      // printing values of TreeMap
14      System.out.println("TreeMap: " + tm);
15      try
16      {
17         // passing null as parameter to floorKey() method
18         System.out.println(tm.floorKey(null));
19      }
20      catch(Exception ex)
21      {
22         System.out.println("Exception: " + ex);
23      }
24   }
25}