Originally posted by Ajith Kallambella:
For an indexed access [ such as get(i) ], their performance should be fairly comparable,
Sorry, beg to differ. LinkedList.get(int) has to count links from the beginning of the list, meaning you have to do O(N) operations to access element N. If you do a "for" loop and access each element of a LinkedList using get(int), then you'll visit 1, 2, 3, ... N elements in total, making such a loop O(N^2) ! This is why using Iterator (or ListIterator) for a list is so important, because a LinkedList Iterator knows how to walk the links.
Accessing any element in an ArrayList takes constant time -- it's a simple array access, O(1). Therefore ArrayList.get(int) is
much faster for large lists.