I was wondering what has better performance when using ArrayList’s:
- A for:each loop, ie:
…make an ArrayList arT…
for (T : arT) {
…handle T
}
- Iterators, ie:
…make an ArrayList art…
Iterator it=arT.iterator();
while(it.hasNext()) {
…handle it.next()
}
- Indexed acces (mind you this is for ArrayLists, not LinkedLists)
for (int i=0;i<arT.size()-1;i++) {
…handle arT.get(i)
}