![]() |
VOOZH | about |
The descendingIterator() method of java.util.TreeSet<E> class is used to return an iterator over the elements in this set in descending order.
Syntax:
public Iterator descendingIterator()
Return Value: This method returns an iterator over the elements in this set in descending order.
Below are the examples to illustrate the descendingIterator() method
Example 1:
TreeSet: [10, 20, 30, 40] Values using DescendingIterator: Value : 40 Value : 30 Value : 20 Value : 10
Example 2:
TreeSet: [A, B, C, D] Values using DescendingIterator: Value : D Value : C Value : B Value : A