I know that we can iterate over the list in the reverse order as follows:
List<Object> lst;
ListIterator<Object> i = lst.listIterator(lst.size());
But is it efficient if lst
is a LinkedList
? I mean when we obtain the ListIterator
pointing to the end of the list, does the implementation iterate over the list from the begging to the list.size()
position (takes O(n)
time, where n
is a size of the list)?
If it does, is there a way to avoid it?