TreeSet lower Example
TreeSet class lower example. This example shows you how to use lower method.
TreeSet class lower example. public Object lower(Object e) Returns the greatest element in this set strictly less than the given element, or null if there is no such element.
Here is the code
/**
* @ # Lower.java
* A class repersenting use to Lower method
* of TreeSet class in java.util package
* version 23 May 2008
* author Rose India
*/
import java.util.*;
public class Lower {
public static void main(String[] args) {
// Create a new TreeSet object:
TreeSet treeset = new TreeSet();
// Create new element object and Add the elementreeset to the set:
treeset.add(new Integer(2));
treeset.add(new Integer(5));
treeset.add(new Integer(7));
System.out.println("treeset = " + treeset);
System.out.println("Lower element : " + treeset.lower(7));
}
} |
Output
treeset = [2, 5, 7]
Lower element : 5 |
|