Online Java Compiler By
JavaTpoint.com
import java.util.ArrayDeque; import java.util.Deque; import java.util.Iterator; public class JavaDequedescendingIteratorExample1 { public static void main(String[] args) { Deque
deque = new ArrayDeque<>(); System.out.println("The list of numbers before using descendingIterator : "); deque.add(32); deque.add(21); deque.add(20); deque.add(17); deque.add(89); for (Integer integer : deque) { System.out.println(integer); } System.out.println("The list of numbers after using descendingIterator :"); Iterator
iterator= deque.descendingIterator(); while(iterator.hasNext()) { System.out.println(iterator.next()); } } }
Output