TreeSet : subSet(), isEmpty(), pollFirst()

The subSet() methods returns a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive. The isEmpty() methods returns true if this set contains no elements. The pollFirst() methods retrieves and removes the first (lowest) element, or returns null if this set is empty. Program       Program Source import java.util.TreeSet; public class Javaapp … Read more…

Java TreeSet : ceiling(), floor(), headSet(), tailSet()

The ceiling() method returns the least element in this set greater than or equal to the given element, or null if there is no such element. The floor() method returns the greatest element in this set less than or equal to the given element, or null if there is no such element. The headset() method returns a view of … Read more…

TreeSet : first(), last(), lower(), higher(), descendingSet()

The first() method returns the first (lowest) element currently in this set. The last() method returns the last (highest) element currently in this set. The lower() method returns the greatest element in this set strictly less than the given element, or null if there is no such element. The higher() method returns the least element in this … Read more…

Java TreeSet

TreeSet extends AbstractSet and implements the NavigableSet interface. It creates a collection that uses a tree for storage. Objects are stored in sorted, ascending order. Access and retrieval times are quite fast, which makes TreeSet an excellent choice when storing large amounts of sorted information that must be found quickly. TreeSet has the following constructors: … Read more…