treeset lower java code example
Example 1: TreeSet lower() method in java
TreeSet lower() method for NullPointerException.
import java.util.TreeSet;
public class TreeSetLowerMethodExample
{
public static void main(String[] args)
{
TreeSet<Integer> ts = new TreeSet<Integer>();
try
{
ts.add(15);
ts.add(8);
ts.add(3);
ts.add(2);
ts.add(10);
ts.add(5);
System.out.println(ts.lower(null));
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}
Example 2: TreeSet lower() method in java
import java.util.TreeSet;
public class TreeSetLowerMethodExample
{
public static void main(String[] args)
{
TreeSet<Integer> ts = new TreeSet<Integer>();
ts.add(15);
ts.add(8);
ts.add(3);
ts.add(2);
ts.add(10);
ts.add(5);
System.out.println(ts.lower(18));
}
}