Quantcast
Channel: When to use LinkedList over ArrayList in Java? - Stack Overflow
Browsing all 35 articles
Browse latest View live

Answer by Krusty the Clown for When to use LinkedList over ArrayList in Java?

I haven't seen any mention of this yet (maybe I missed it among the 30+ answers...), but you should ALWAYS prefer an ArrayList over a LinkedList if you know what the final size of your collection will...

View Article



Answer by Boris Fain for When to use LinkedList over ArrayList in Java?

First of all use Vector instead ArrayList because you can overrite insureCapasity method ,in ArrayList is private and add 1.5 size of current array...

View Article

Answer by Sina Madani for When to use LinkedList over ArrayList in Java?

My rule of thumb is if I need a Collection (i.e. doesn't need to be a List) then use ArrayList if you know the size in advance, or can know the size confidently, or know that it won't vary much. If you...

View Article

Answer by Gayan Weerakutti for When to use LinkedList over ArrayList in Java?

You can use one over the other based on the time complexities of the operations that you'd perform on that particular...

View Article

Image may be NSFW.
Clik here to view.

Answer by Lior Bar-On for When to use LinkedList over ArrayList in Java?

TL;DR due to modern computer architecture, ArrayList will be significantly more efficient for nearly any possible use-case - and therefore LinkedList should be avoided except some very unique and...

View Article


Answer by Jose Martinez for When to use LinkedList over ArrayList in Java?

One of the tests I saw on here only conducts the test once. But what I have noticed is that you need to run these tests many times and eventually their times will converge. Basically the JVM needs to...

View Article

Answer by Anjali Suman for When to use LinkedList over ArrayList in Java?

1) Underlying Data StructureThe first difference between ArrayList and LinkedList comes with the fact that ArrayList is backed by Array while LinkedList is backed by LinkedList. This will lead to...

View Article

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

ArrayList extends AbstractList and implements the List Interface. ArrayList is dynamic array.It can be said that it was basically created to overcome the drawbacks of arraysThe LinkedList class extends...

View Article


Answer by Nesan Mano for When to use LinkedList over ArrayList in Java?

ArrayList and LinkedList have their own pros and cons.ArrayList uses contiguous memory address compared to LinkedList which uses pointers toward the next node. So when you want to look up an element in...

View Article


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

Joshua Bloch, the author of LinkedList:Does anyone actually use LinkedList? I wrote it, and I never use it.Link: https://twitter.com/joshbloch/status/583813919019573248I'm sorry for the answer not...

View Article

Answer by Abhijeet Ashok Muneshwar for When to use LinkedList over ArrayList...

Let's compare LinkedList and ArrayList w.r.t. below parameters:1. ImplementationArrayList is the resizable array implementation of list interface , while LinkedList is the Doubly-linked list...

View Article

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

ArrayList and LinkedList both implements List interface and their methods and results are almost identical. However there are few differences between them which make one better over another depending...

View Article

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

Both remove() and insert() have a runtime efficiency of O(n) for both ArrayLists and LinkedLists. However, the reason behind the linear processing time comes from two very different reasons:In an...

View Article


Answer by 王奕然 for When to use LinkedList over ArrayList in Java?

Operation get(i) in ArrayList is faster than LinkedList, because:ArrayList: Resizable-array implementation of the List interfaceLinkedList: Doubly-linked list implementation of the List and Deque...

View Article

Image may be NSFW.
Clik here to view.

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

ArrayList is essentially an array. LinkedList is implemented as a double linked list. The get is pretty clear. O(1) for ArrayList, because ArrayList allow random access by using index. O(n) for...

View Article


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

I know this is an old post, but I honestly can't believe nobody mentioned that LinkedList implements Deque. Just look at the methods in Deque (and Queue); if you want a fair comparison, try running...

View Article

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:ArrayListget O(1)add O(1)contains O(n)next O(1)remove O(n)iterator.remove O(n)LinkedListget O(n)add...

View Article


Answer by Ilya Gazman for When to use LinkedList over ArrayList in Java?

When should I use LinkedList? When working with stacks mostly, or when working with buffers.When should I use ArrayList? Only when working with indexes, otherwise you can use HashTable with linked...

View Article

Image may be NSFW.
Clik here to view.

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

Thus far, nobody seems to have addressed the memory footprint of each of these lists besides the general consensus that a LinkedList is "lots more" than an ArrayList so I did some number crunching to...

View Article

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

I have read the responses, but there is one scenario where I always use a LinkedList over an ArrayList that I want to share to hear opinions:Every time I had a method that returns a list of data...

View Article
Browsing all 35 articles
Browse latest View live


Latest Images