Depending on the implementation, List
and ListIterator
may be (slightly) faster.
List l; for (int i = l.size()-1; i >=0; i--) { System.out.println(l.get(i)); }
It may be faster for ArrayList
, but it will almost certainly be slower for LinkedList
.
It is best to use an iterator.
Almost certainly, any work that you do in a loop will negate any performance obtained by using an iterator.
jjnguy
source share