Java TreeSet.lower(E e)

Syntax

TreeSet.lower(E e) has the following syntax.

public E lower(E e)

Example

In the following code shows how to use TreeSet.lower(E e) method.


/*from  w  ww.  j  a v a  2  s  . co m*/
import java.util.TreeSet;

public class Main {
   public static void main(String[] args) {
      
      TreeSet<Integer> treeadd = new TreeSet<Integer> ();
     
      treeadd.add(1);
      treeadd.add(3);
      treeadd.add(17);
      treeadd.add(2);
      treeadd.add(20);
     
      // displaying the greatest element < 17
      System.out.println("Greatest element less than 17 is: "+treeadd.lower(17));    
   }     
}

The code above generates the following result.