Java TreeSet descendingSet() Method Example

The descendingIterator() method of java.util.TreeSet class will return an iterator over the elements in this set in descending order whereas descendingSet() method returns a reverse order view of the elements contained in this set. The descending set is backed by this set, so changes to the set are reflected in the descending set, and vice-versa. If either set is modified while an iteration over either set is in progress (except through the iterator’s own remove operation), the results of the iteration are undefined. [Read more…]