treeset floor 28 29 method in java

Solutions on MaxInterview for treeset floor 28 29 method in java by the best coders in the world

showing results for - "treeset floor 28 29 method in java"
María Camila
24 Jan 2016
1import java.util.TreeSet;
2public class TreeSetFloorMethodExample
3{
4   public static void main(String[] args)
5   {
6      try
7      {
8         TreeSet<Integer> ts = new TreeSet<Integer>();
9         ts.add(50);
10         ts.add(60);
11         ts.add(70);
12         ts.add(80);
13         System.out.println("Given TreeSet: " + ts);
14         // get floor value for 65 using floor() method
15         int value = ts.floor(65);
16         // print floor value
17         System.out.println("Floor value for 65 is : " + value);
18      }
19      catch(NullPointerException ex)
20      {
21         System.out.println("Exception: " + ex);
22      }
23   }
24}
Isidora
03 Mar 2020
1floor() method for NullPointerException.
2import java.util.TreeSet;
3public class TreeSetFloorMethodExample
4{
5   public static void main(String[] args)
6   {
7      try
8      {
9         TreeSet<Integer> ts = new TreeSet<Integer>();
10         ts.add(50);
11         ts.add(60);
12         ts.add(70);
13         ts.add(80);
14         System.out.println("Given TreeSet: " + ts);
15         // get floor value for null using floor() method
16         System.out.println("Get floor value for null: ");
17         int value = ts.floor(null);
18         // print floor value
19         System.out.println("Floor value for 65: " + value);
20      }
21      catch(NullPointerException ex)
22      {
23         System.out.println("Exception: " + ex);
24      }
25   }
26}