ArrayDeque descendingIterator() Method in Java
The Java.util.ArrayDeque.descendingIterator() method is used to return an iterator of the same elements as the ArrayDeque but in the reverse order.
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.
Iterator iterate_value = Array_Deque.descendingIterator();
Parameters: The method does not take any parameter.
Return Value: The method iterates over the elements of the deque and returns the values(iterators) in reverse order.
Below programs illustrate the Java.util.ArrayDeque.descendingIterator() method:
ArrayDeque: [Welcome, To, Geeks, 4, Geeks] The iterator values are: Geeks 4 Geeks To Welcome
ArrayDeque: [10, 15, 30, 20, 5] The iterator values are: 5 20 30 15 10