see Collection interface for descriptions and examples of most of TreeSet's methods
■ Like HashSet, TreeSet extends the AbstractSet class. But it also implements the SortedSet interface. It is for creating an automatically ordered set, with no duplicates, in ascending order. Like all Sets, TreeSet allows just one null element.
■ TreeSet is for sorted collections. In general, when you use TreeSet instead of ArrayList, you are giving up your ability to have duplicate elements in return for having your items naturally sorted. You also will have somewhat fewer methods with which to work.
■ TreeSet
adds five methods to the familiar Collection
methods. They are: .first( ),
.headSet(...), .last( ),
.subSet(...), .tailSet(...).
■ Returns first/last element or NoSuchElementException if set is empty.
■ Returns first/last element or NoSuchElementException if set is empty.
■ Returns a (live) SortedSet view of all elements less/higher than the Obj, exclusive of Obj
■ Returns a (live) SortedSet view of all elements less/higher than the Obj, exclusive of Obj
■ Returns a (live) SortedSet view of all elements inclusive of the first Obj, to the last one exclusive of the final Obj