r/javahelp • u/LFrancis • Apr 30 '20
ArrayList vs LinkedList
So I understand that for different situations, either the ArrayList API or the LinkedList API will be more efficient. So what should I look for in terms of design that will tell me which one of those structures is recommended? Is it more related to preference rather than specific uses?
Thanks!
17
Upvotes
1
u/mrorok Apr 30 '20
LinkedList are only good when you need to do lots of insertions and deletions as they can insert and delete in O(1). Whereas an ArrayList does so in O(n) because you need shift the called because the underlying data structure is an array. So depending on what you need to do it may be useful