Quantcast
Viewing all articles
Browse latest Browse all 36

Answer by Rajith Delantha for When to use LinkedList over ArrayList in Java?

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. :)


Viewing all articles
Browse latest Browse all 36

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>