Here is the Big-O notation in both ArrayList
and LinkedList
and also CopyOnWrite-ArrayList
:
ArrayList
get O(1)add O(1)contains O(n)next O(1)remove O(n)iterator.remove O(n)
LinkedList
get O(n)add O(1)contains O(n)next O(1)remove O(1)iterator.remove O(1)
CopyOnWrite-ArrayList
get O(1)add O(n)contains O(n)next O(1)remove O(n)iterator.remove O(n)
Based on these you have to decide what to choose. :)