Q:

How can i iterate a ArrayDeque in reverse?

How can i iterate a ArrayDeque in reverse?
I would normally do this for an array but it's not indexable.
for (int i = delegate.size() - 1; i >= 0; i--) {}

thanks

A:

You can use the method descendingIterator() to get an iterator that iterates the ArrayDeque<T> in reverse.
Iterator<T> it = arrayDeque.descendingIterator();
while(it.hasNext()) {
    // do something with it.next()
}

