treeset lower 28 29 method in java

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

showing results for - "treeset lower 28 29 method in java"
Paola
13 Jul 2019
1import java.util.TreeSet;
2public class TreeSetLowerMethodExample
3{
4   public static void main(String[] args)
5   {
6      TreeSet<Integer> ts = new TreeSet<Integer>();
7      ts.add(15);
8      ts.add(8);
9      ts.add(3);
10      ts.add(2);
11      ts.add(10);
12      ts.add(5);
13      System.out.println(ts.lower(18));
14   }
15}
16
17
18
Giorgio
17 May 2020
1TreeSet lower() method for ClassCastException.
2import java.util.ArrayList;
3import java.util.LinkedList;
4import java.util.List;
5import java.util.TreeSet;
6public class TreeSetLowerMethodExample
7{
8   public static void main(String[] args)
9   {
10      TreeSet<List> ts = new TreeSet<List>();
11      List<Integer> li1 = new LinkedList<Integer>();
12      li1.add(10);
13      li1.add(20);
14      ts.add(li1);
15      List<Integer> li2 = new LinkedList<Integer>();
16      li2.add(30);
17      li2.add(40);
18      List<Integer> li3 = new ArrayList<Integer>();
19      li2.add(50);
20      li2.add(60);
21      try
22      {
23         System.out.println(ts.lower(li3));
24      }
25      catch(Exception ex)
26      {
27         System.out.println(ex);
28      }
29   }
30}
Erik
01 Jun 2019
1TreeSet lower() method for NullPointerException.
2import java.util.TreeSet;
3public class TreeSetLowerMethodExample
4{
5   public static void main(String[] args)
6   {
7      TreeSet<Integer> ts = new TreeSet<Integer>();
8      try
9      {
10         ts.add(15);
11         ts.add(8);
12         ts.add(3);
13         ts.add(2);
14         ts.add(10);
15         ts.add(5);
16         System.out.println(ts.lower(null));
17      }
18      catch(Exception ex)
19      {
20         ex.printStackTrace();
21      }
22   }
23}
24
25
26