In this article we will discuss how to iterate over a LinkedList in reverse order.

Method 1 : Using Descending Iterator

Descending Iterator returns the Iterator that points to the end of of List i.e.

Now calling function next() with descending iterator will return the previous element and also moves the cursor by one position backward. Also, hasNext() will tell if previous element is available or not i.e.

Method 2 : Using Normal List Iterator

Get the list iterator that with index location List Size. This will make the iterator point to the end of List.

Now, use the ListIterator’s hasPrevious() function to check if previous element is present or not.

Then previous() function to fetch the previous element and move the cursor to previous element i.e.

Checkout the complete example to iterate over a LinkedList using both the above two methods as follows,



Click Here to Subscribe for more Articles / Tutorials like this.