treemap floorentry 28 29 method in java

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

showing results for - "treemap floorentry 28 29 method in java"
Giuseppe
14 Oct 2018
1import java.util.TreeMap;
2public class TreeMapFloorEntryMethodExample
3{
4   public static void main(String[] args)
5   {
6      TreeMap<Integer, String> tm = new TreeMap<Integer, String>();
7      tm.put(63, "orange");
8      tm.put(50, "apple");
9      tm.put(83, "watermelon");
10      tm.put(86, "banana");
11      tm.put(56, "mango");
12      System.out.println("Check floor entry for 86: ");
13      System.out.println("Value is: " + tm.floorEntry(86));
14   }
15}
Dante
20 May 2020
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}