TreeSet.floor(E e) has the following syntax.
public E floor(E e)
In the following code shows how to use TreeSet.floor(E e) method.
/* w w w . j a v a2s .c o m*/ import java.util.TreeSet; 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 the floor value for 13 System.out.println("Floor value for 13: "+treeadd.floor(13)); } }
The code above generates the following result.