I will assume that your premise is true that "linkedList is faster than ArrayList from iterating point of view."
A look at the class' hierarchies and their interfaces reveals the following:
Judging simply by the collections' superclasses' names and their interfaces, I'd think that LinkedList would be faster to iterate over the entire collection because LinkedList has a superclass called AbstractSequentialList, which may be aptly named because of its underlying implementation.
ArrayList implements an interface named RandomAccess, which again seems to hint at some underlying functinality. The RandomAccess interface indicates to me that seeking any single member via random access should be faster than through iterating over the entire collection via sequential access.
Your question is "Why (is) LinkedList faster than ArrayList from iterating point of view?" My answer, based solely on the interface and superclass names is that iterating over an entire collection is faster (or, at least by my intuition, should not be slower) via sequential than random access.
Mathangi, I agree with you on the fact that ArrayList is not synchronized. However, LinkList is not synchronized either. It is only the Vector which is synchronized. One more thing to add, LinkList IS FASTER than ArrayList for iterating. Please follow this link here for more details.
Thanks to both of you.
Post by:autobot
My name is Inigo Montoya, you killed my father, prepare to read a tiny ad:
a bit of art, as a gift, the permaculture playing cards