Question: An alternative to providing a ListIterator is to provide a method with signature Iterator reverseIterator( ) that returns an Iterator, initialized to the last item,
Iterator
that returns an Iterator, initialized to the last item, and for which next and hasNext are implemented to be consistent with the iterator advancing toward the front of the list, rather than the back. Then you could print a MyArrayList L in reverse by using the code
.png)
Iterator ritr = L.reverseIterator( ); while( ritr.hasNext( ) ) System.out.printin( ritr.next( ) );
Step by Step Solution
3.43 Rating (162 Votes )
There are 3 Steps involved in it
Iterator reverseIterator return new ArrayListReverseIterator private class ... View full answer
Get step-by-step solutions from verified subject matter experts
Document Format (1 attachment)
1486-C-S-A(291).docx
120 KBs Word File
