java set ceiling code example
Example 1: TreeSet ceiling() method in java
import java.util.TreeSet;
public class TreeSetCeilingMethodExample
{
public static void main(String[] args)
{
try
{
TreeSet<Integer> ts = new TreeSet<Integer>();
ts.add(50);
ts.add(60);
ts.add(70);
ts.add(80);
System.out.println("TreeSet values: " + ts);
int value = ts.ceiling(65);
System.out.println("Ceiling value for 65: " + value);
}
catch(NullPointerException ex)
{
System.out.println("Exception: " + ex);
}
}
}
Example 2: TreeSet ceiling() method in java
TreeSet ceiling() method for NullPointerException.
import java.util.TreeSet;
public class TreeSetCeilingMethodExample
{
public static void main(String[] args)
{
try
{
TreeSet<Integer> ts = new TreeSet<Integer>();
ts.add(50);
ts.add(60);
ts.add(70);
ts.add(80);
System.out.println("TreeSet values: " + ts);
System.out.println("compare with null value: ");
int value = ts.ceiling(null);
System.out.println("Ceiling value for null: " + value);
}
catch(NullPointerException ex)
{
System.out.println("Exception: " + ex);
}
}
}