I was going through ArrayList internal implementation in Java and I found that ArrayList is dynamically increasing array and when the size gets increased , a new space is allocated and the previous records are moved there.So, when a large list is to be filled and the capacity is not known it is not recomended to use ArrayList.
The replacement that came to my mind was LinkedList.Going through LinkedList implementation but I have two consern
When a for each loop is been executed does it means that everytime a node is been accessed it will traverse all the previous node .That will make worst case as o(n^2).
If an iterator is used in the place of foreach wil it contribute anything to the performance or how does it differ from foreach.
Thank you for your reply in advance..