treeset ceiling 28 29 method in java

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

showing results for - "treeset ceiling 28 29 method in java"
Helena
02 Jun 2020
1TreeSet ceiling() method for NullPointerException.
2import java.util.TreeSet;
3public class TreeSetCeilingMethodExample
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("TreeSet values: " + ts);
15         // get ceiling value for null using ceiling() method
16         System.out.println("compare with null value: ");
17         int value = ts.ceiling(null);
18         // print the ceiling value
19         System.out.println("Ceiling value for null: " + value);
20      }
21      catch(NullPointerException ex)
22      {
23         System.out.println("Exception: " + ex);
24      }
25   }
26}
Aurore
28 Mar 2016
1import java.util.TreeSet;
2public class TreeSetCeilingMethodExample
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("TreeSet values: " + ts);
14         // get ceiling value for 65 using ceiling() method
15         int value = ts.ceiling(65);
16         // print the ceiling value
17         System.out.println("Ceiling value for 65: " + value);
18      }
19      catch(NullPointerException ex)
20      {
21         System.out.println("Exception: " + ex);
22      }
23   }
24}