TreeSet.ceiling(E e) has the following syntax.
public E ceiling(E e)
In the following code shows how to use TreeSet.ceiling(E e) method.
import java.util.Iterator; import java.util.TreeSet; /*w w w. java 2 s. c om*/ public class Main { public static void main(String[] args) { TreeSet <Integer> treeadd = new TreeSet<Integer> (); treeadd.add(12); treeadd.add(11); treeadd.add(16); treeadd.add(15); // getting ceiling value for 13 System.out.println("Ceiling value for 13: "+treeadd.ceiling(13)); } }
The code above generates the following result.