Summary ArrayList with ArrayDeque are preferable in many more use-cases than LinkedList. If you're not sure — just start with ArrayList.


TLDR, in ArrayList accessing an element takes constant time [O(1)] and adding an element takes O(n) time [worst case]. In LinkedList inserting an element takes O(n) time and accessing also takes O(n) time but LinkedList uses more memory than ArrayList.

LinkedList and ArrayList are two different implementations of the List interface. LinkedList implements it with a doubly-linked list. ArrayList implements it with a dynamically re-sizing array.

As with standard linked list and array operations, the various methods will have different algorithmic runtimes.

For LinkedList<E>

  • get(int index) is O(n) (with n/4 steps on average), but O(1) when index = 0 or index = list.size() - 1 (in this case, you can also use getFirst() and getLast()).
  • add(int index, E element) is O(n) (with n/4 steps on average), but O(1) when index = 0 or index = list.size() - 1 (in this case, you can also use addFirst() and addLast()/add()). One of the main benefits of LinkedList<E>
  • remove(int index) is O(n) (with n/4 steps on average), but O(1) when index = 0 or index = list.size() - 1 (in this case, you can also use removeFirst() and removeLast()). One of the main benefits of LinkedList<E>
  • Iterator.remove() is O(1). One of the main benefits of LinkedList<E>
  • ListIterator.add(E element) is O(1). One of the main benefits of LinkedList<E>

Note: Many of the operations need n/4 steps on average, constant number of steps in the best case (e.g. index = 0), and n/2 steps in worst case (middle of list)

For ArrayList<E>

  • get(int index) is O(1). Main benefit of ArrayList<E>
  • add(E element) is O(1) amortized, but O(n) worst-case since the array must be resized and copied
  • add(int index, E element) is O(n) (with n/2 steps on average)
  • remove(int index) is O(n) (with n/2 steps on average)
  • Iterator.remove() is O(n) (with n/2 steps on average)
  • ListIterator.add(E element) is O(n) (with n/2 steps on average)

Note: Many of the operations need n/2 steps on average, constant number of steps in the best case (end of list), n steps in the worst case (start of list)

LinkedList<E> allows for constant-time insertions or removals using iterators, but only sequential access of elements. In other words, you can walk the list forwards or backwards, but finding a position in the list takes time proportional to the size of the list. Javadoc says "operations that index into the list will traverse the list from the beginning or the end, whichever is closer", so those methods are O(n) (n/4 steps) on average, though O(1) for index = 0.

ArrayList<E>, on the other hand, allow fast random read access, so you can grab any element in constant time. But adding or removing from anywhere but the end requires shifting all the latter elements over, either to make an opening or fill the gap. Also, if you add more elements than the capacity of the underlying array, a new array (1.5 times the size) is allocated, and the old array is copied to the new one, so adding to an ArrayList is O(n) in the worst case but constant on average.

So depending on the operations you intend to do, you should choose the implementations accordingly. Iterating over either kind of List is practically equally cheap. (Iterating over an ArrayList is technically faster, but unless you're doing something really performance-sensitive, you shouldn't worry about this -- they're both constants.)

The main benefits of using a LinkedList arise when you re-use existing iterators to insert and remove elements. These operations can then be done in O(1) by changing the list locally only. In an array list, the remainder of the array needs to be moved (i.e. copied). On the other side, seeking in a LinkedList means following the links in O(n) (n/2 steps) for worst case, whereas in an ArrayList the desired position can be computed mathematically and accessed in O(1).

Another benefit of using a LinkedList arises when you add or remove from the head of the list, since those operations are O(1), while they are O(n) for ArrayList. Note that ArrayDeque may be a good alternative to LinkedList for adding and removing from the head, but it is not a List.

Also, if you have large lists, keep in mind that memory usage is also different. Each element of a LinkedList has more overhead since pointers to the next and previous elements are also stored. ArrayLists don't have this overhead. However, ArrayLists take up as much memory as is allocated for the capacity, regardless of whether elements have actually been added.

The default initial capacity of an ArrayList is pretty small (10 from Java 1.4 - 1.8). But since the underlying implementation is an array, the array must be resized if you add a lot of elements. To avoid the high cost of resizing when you know you're going to add a lot of elements, construct the ArrayList with a higher initial capacity.

If the data structures perspective is used to understand the two structures, a LinkedList is basically a sequential data structure which contains a head Node. The Node is a wrapper for two components : a value of type T [accepted through generics] and another reference to the Node linked to it. So, we can assert it is a recursive data structure (a Node contains another Node which has another Node and so on...). Addition of elements takes linear time in LinkedList as stated above.

An ArrayList is a growable array. It is just like a regular array. Under the hood, when an element is added, and the ArrayList is already full to capacity, it creates another array with a size which is greater than previous size. The elements are then copied from previous array to new one and the elements that are to be added are also placed at the specified indices.

Top answer
1 of 16
3899

Summary ArrayList with ArrayDeque are preferable in many more use-cases than LinkedList. If you're not sure — just start with ArrayList.


TLDR, in ArrayList accessing an element takes constant time [O(1)] and adding an element takes O(n) time [worst case]. In LinkedList inserting an element takes O(n) time and accessing also takes O(n) time but LinkedList uses more memory than ArrayList.

LinkedList and ArrayList are two different implementations of the List interface. LinkedList implements it with a doubly-linked list. ArrayList implements it with a dynamically re-sizing array.

As with standard linked list and array operations, the various methods will have different algorithmic runtimes.

For LinkedList<E>

  • get(int index) is O(n) (with n/4 steps on average), but O(1) when index = 0 or index = list.size() - 1 (in this case, you can also use getFirst() and getLast()).
  • add(int index, E element) is O(n) (with n/4 steps on average), but O(1) when index = 0 or index = list.size() - 1 (in this case, you can also use addFirst() and addLast()/add()). One of the main benefits of LinkedList<E>
  • remove(int index) is O(n) (with n/4 steps on average), but O(1) when index = 0 or index = list.size() - 1 (in this case, you can also use removeFirst() and removeLast()). One of the main benefits of LinkedList<E>
  • Iterator.remove() is O(1). One of the main benefits of LinkedList<E>
  • ListIterator.add(E element) is O(1). One of the main benefits of LinkedList<E>

Note: Many of the operations need n/4 steps on average, constant number of steps in the best case (e.g. index = 0), and n/2 steps in worst case (middle of list)

For ArrayList<E>

  • get(int index) is O(1). Main benefit of ArrayList<E>
  • add(E element) is O(1) amortized, but O(n) worst-case since the array must be resized and copied
  • add(int index, E element) is O(n) (with n/2 steps on average)
  • remove(int index) is O(n) (with n/2 steps on average)
  • Iterator.remove() is O(n) (with n/2 steps on average)
  • ListIterator.add(E element) is O(n) (with n/2 steps on average)

Note: Many of the operations need n/2 steps on average, constant number of steps in the best case (end of list), n steps in the worst case (start of list)

LinkedList<E> allows for constant-time insertions or removals using iterators, but only sequential access of elements. In other words, you can walk the list forwards or backwards, but finding a position in the list takes time proportional to the size of the list. Javadoc says "operations that index into the list will traverse the list from the beginning or the end, whichever is closer", so those methods are O(n) (n/4 steps) on average, though O(1) for index = 0.

ArrayList<E>, on the other hand, allow fast random read access, so you can grab any element in constant time. But adding or removing from anywhere but the end requires shifting all the latter elements over, either to make an opening or fill the gap. Also, if you add more elements than the capacity of the underlying array, a new array (1.5 times the size) is allocated, and the old array is copied to the new one, so adding to an ArrayList is O(n) in the worst case but constant on average.

So depending on the operations you intend to do, you should choose the implementations accordingly. Iterating over either kind of List is practically equally cheap. (Iterating over an ArrayList is technically faster, but unless you're doing something really performance-sensitive, you shouldn't worry about this -- they're both constants.)

The main benefits of using a LinkedList arise when you re-use existing iterators to insert and remove elements. These operations can then be done in O(1) by changing the list locally only. In an array list, the remainder of the array needs to be moved (i.e. copied). On the other side, seeking in a LinkedList means following the links in O(n) (n/2 steps) for worst case, whereas in an ArrayList the desired position can be computed mathematically and accessed in O(1).

Another benefit of using a LinkedList arises when you add or remove from the head of the list, since those operations are O(1), while they are O(n) for ArrayList. Note that ArrayDeque may be a good alternative to LinkedList for adding and removing from the head, but it is not a List.

Also, if you have large lists, keep in mind that memory usage is also different. Each element of a LinkedList has more overhead since pointers to the next and previous elements are also stored. ArrayLists don't have this overhead. However, ArrayLists take up as much memory as is allocated for the capacity, regardless of whether elements have actually been added.

The default initial capacity of an ArrayList is pretty small (10 from Java 1.4 - 1.8). But since the underlying implementation is an array, the array must be resized if you add a lot of elements. To avoid the high cost of resizing when you know you're going to add a lot of elements, construct the ArrayList with a higher initial capacity.

If the data structures perspective is used to understand the two structures, a LinkedList is basically a sequential data structure which contains a head Node. The Node is a wrapper for two components : a value of type T [accepted through generics] and another reference to the Node linked to it. So, we can assert it is a recursive data structure (a Node contains another Node which has another Node and so on...). Addition of elements takes linear time in LinkedList as stated above.

An ArrayList is a growable array. It is just like a regular array. Under the hood, when an element is added, and the ArrayList is already full to capacity, it creates another array with a size which is greater than previous size. The elements are then copied from previous array to new one and the elements that are to be added are also placed at the specified indices.

2 of 16
706

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 demonstrate exactly how much both lists take up for N null references.

Since references are either 32 or 64 bits (even when null) on their relative systems, I have included 4 sets of data for 32 and 64 bit LinkedLists and ArrayLists.

Note: The sizes shown for the ArrayList lines are for trimmed lists - In practice, the capacity of the backing array in an ArrayList is generally larger than its current element count.

Note 2: (thanks BeeOnRope) As CompressedOops is default now from mid JDK6 and up, the values below for 64-bit machines will basically match their 32-bit counterparts, unless of course you specifically turn it off.



The result clearly shows that LinkedList is a whole lot more than ArrayList, especially with a very high element count. If memory is a factor, steer clear of LinkedLists.

The formulas I used follow, let me know if I have done anything wrong and I will fix it up. 'b' is either 4 or 8 for 32 or 64 bit systems, and 'n' is the number of elements. Note the reason for the mods is because all objects in java will take up a multiple of 8 bytes space regardless of whether it is all used or not.

ArrayList:

ArrayList object header + size integer + modCount integer + array reference + (array oject header + b * n) + MOD(array oject, 8) + MOD(ArrayList object, 8) == 8 + 4 + 4 + b + (12 + b * n) + MOD(12 + b * n, 8) + MOD(8 + 4 + 4 + b + (12 + b * n) + MOD(12 + b * n, 8), 8)

LinkedList:

LinkedList object header + size integer + modCount integer + reference to header + reference to footer + (node object overhead + reference to previous element + reference to next element + reference to element) * n) + MOD(node object, 8) * n + MOD(LinkedList object, 8) == 8 + 4 + 4 + 2 * b + (8 + 3 * b) * n + MOD(8 + 3 * b, 8) * n + MOD(8 + 4 + 4 + 2 * b + (8 + 3 * b) * n + MOD(8 + 3 * b, 8) * n, 8)

🌐
DEV Community
dev.to › digitalcrafting › java-benchmark-adventures-arraylist-vs-linkedlist-4oho
Java Benchmark Adventures - ArrayList vs LinkedList - DEV Community
February 4, 2024 - As for the last element: the performance for ArrayList and LinkedList is pretty much the same, because Java implementation of LinkedList holds references to both beginning and end by default.
Discussions

java - Performance differences between ArrayList and LinkedList - Stack Overflow
Yes, this is an old topic, but I still have some confusions. In Java, people say: ArrayList is faster than LinkedList if I randomly access its elements. I think random access means "give me the nth More on stackoverflow.com
🌐 stackoverflow.com
ArrayList has faster insert speed than LinkedList
It’s worth noting your technique for doing performance testing can yield some inaccurate results. As a program executed for a long time the JVM optimizes your code and sections of libraries. Performance of the first time an operation happens may not be the performance of the 1000000th time that happens. Certainly things speed up and your timings will be off. Also, performance and timing can sometimes depend on your machine and how busy it otherwise is. My advice: try putting the whole thing in a for loop with a large counter. Keep track of the final 100 results and average those results together. If you can have many concurrent threads that may make this faster. Then you should have some good results. And even when you do all that, I wouldn’t be surprised to find out that ArrayList is better performance. I’ve also found in my testing that I get better performance from a properly sized ArrayList than a linked list. I haven’t seen any advice on how to get better perf from a linked list. Also while you’re down the rabbit hole, try testing different maps! More on reddit.com
🌐 r/javahelp
23
8
August 6, 2022
Choosing between ArrayList and LinkedList - JEP Cafe #20
The issue is that even tho linked list can have theoretically better complexity in some cases, in reality an array list with contiguous memory will outperform it. More on reddit.com
🌐 r/java
15
25
October 11, 2023
ArrayList vs LinkedList
ArrayList is still better in most cases, but this is a good one to be familiar with. ... LinkedList has additional node object that keeps reference to value object, so it's unnecessary overhead. Whenever you would need a linked list in your code, intrusive linked list is better for performance/me... More on reddit.com
🌐 r/learnjava
15
46
December 21, 2020
🌐
Reddit
reddit.com › r/javahelp › arraylist has faster insert speed than linkedlist
r/javahelp on Reddit: ArrayList has faster insert speed than LinkedList
August 6, 2022 -

My task needs to frequently insert element to a collection. LinkedList should be a good option, so I decided to test it against ArrayList, using the following snipper of code (it's Kotlin but it's still use java's ArrayList and LinkedList).

@Test
fun test1() {
    val elementsCount = 9999999

    val linkedListTime = measureNanoTime {
        val list = LinkedList<Int>()

        for (i in 0 until elementsCount) {
            list.add(1)
        }
    }

    val arrayListTime = measureNanoTime {
        val list = ArrayList<Int>()

        for (i in 0 until elementsCount) {
            list.add(1)
        }
    }

    println("Linked list time:")
    println(linkedListTime)
    println("Array list time:")
    println(arrayListTime)
}

The result is that ArrayList has much lower insert time compared to LinkedList

Linked list time:
683270459
Array list time:
223203092

From what I read from online explanation, LinkedList's slower speed has something to do with memory allocation for each element inserted.

ArrayList outperform LinkedList at insertion, which is the only thing that LinkedList is better at. What is LinkedList good for ? What is the use case of LinkedList?

Top answer
1 of 11
80

ArrayList is faster than LinkedList if I randomly access its elements. I think random access means "give me the nth element". Why ArrayList is faster?

ArrayList has direct references to every element in the list, so it can get the n-th element in constant time. LinkedList has to traverse the list from the beginning to get to the n-th element.

LinkedList is faster than ArrayList for deletion. I understand this one. ArrayList's slower since the internal backing-up array needs to be reallocated.

ArrayList is slower because it needs to copy part of the array in order to remove the slot that has become free. If the deletion is done using the ListIterator.remove() API, LinkedList just has to manipulate a couple of references; if the deletion is done by value or by index, LinkedList has to potentially scan the entire list first to find the element(s) to be deleted.

If it means move some elements back and then put the element in the middle empty spot, ArrayList should be slower.

Yes, this is what it means. ArrayList is indeed slower than LinkedList because it has to free up a slot in the middle of the array. This involves moving some references around and in the worst case reallocating the entire array. LinkedList just has to manipulate some references.

2 of 11
38

Ignore this answer for now. The other answers, particularly that of aix, are mostly correct. Over the long term they're the way to bet. And if you have enough data (on one benchmark on one machine, it seemed to be about one million entries) ArrayList and LinkedList do currently work as advertized. However, there are some fine points that apply in the early 21st century.

Modern computer technology seems, by my testing, to give an enormous edge to arrays. Elements of an array can be shifted and copied at insane speeds. As a result arrays and ArrayList will, in most practical situations, outperform LinkedList on inserts and deletes, often dramatically. In other words, ArrayList will beat LinkedList at its own game.

The downside of ArrayList is it tends to hang onto memory space after deletions, where LinkedList gives up space as it gives up entries.

The bigger downside of arrays and ArrayList is they fragment free memory and overwork the garbage collector. As an ArrayList expands, it creates new, bigger arrays, copies the old array to the new one, and frees the old one. Memory fills with big contiguous chunks of free memory that are not big enough for the next allocation. Eventually there's no suitable space for that allocation. Even though 90% of memory is free, no individual piece is big enough to do the job. The GC will work frantically to move things around, but if it takes too long to rearrange the space, it will throw an OutOfMemoryException. If it doesn't give up, it can still slow your program way down.

The worst of it is this problem can be hard to predict. Your program will run fine one time. Then, with a bit less memory available, with no warning, it slows or stops.

LinkedList uses small, dainty bits of memory and GC's love it. It still runs fine when you're using 99% of your available memory.

So in general, use ArrayList for smaller sets of data that are not likely to have most of their contents deleted, or when you have tight control over creation and growth. (For instance, creating one ArrayList that uses 90% of memory and using it without filling it for the duration of the program is fine. Continually creating and freeing ArrayList instances that use 10% of memory will kill you.) Otherwise, go with LinkedList (or a Map of some sort if you need random access). If you have very large collections (say over 100,000 elements), no concerns about the GC, and plan lots of inserts and deletes and no random access, run a few benchmarks to see what's fastest.

🌐
BeginnersBook
beginnersbook.com › 2013 › 12 › difference-between-arraylist-and-linkedlist-in-java
Difference between ArrayList and LinkedList in Java
On the other side LinkedList implements ... 2) Deletion: LinkedList remove operation gives O(1) performance while ArrayList gives variable performance: O(n) in worst case (while removing first element) and O(1) in best case (While removing last element)....
🌐
Stack Abuse
stackabuse.com › difference-between-arraylist-and-linkedlist-in-java-code-and-performance
Difference Between ArrayList and LinkedList in Java - Code and Performance
September 21, 2023 - LinkedList's complexity for inserting in the middle is O(N), the same as for ArrayList. The insertion operation is really efficient, but to get to that point, it has to traverse all previous elements. Generally, inserting elements performs equally between both an ArrayList and a LinkedList, unless you're mainly working with the first and last elements.
🌐
Scaler
scaler.com › home › topics › arraylist vs linkedlist in java
ArrayList vs LinkedList in Java - Scaler Topics
April 3, 2024 - Use ArrayList when you need fast random access and don’t need to do a lot of insertion and deletion. Use LinkedList when you need fast insertion and deletion and don’t need to do a lot of random access. Ultimately, the choice should align with your specific use case and performance priorities, striking a balance between access patterns, data modifications, and memory constraints.
Find elsewhere
🌐
Medium
medium.com › java-performance › performance-arraylist-vs-linked-list-966bde4cfe75
Performance: ArrayList vs Linked List | by Renan Schmitt | Java Performance | Medium
May 10, 2024 - When adding a large number of elements (over 100k), ArrayList demonstrates better performance. The performance difference is related to memory allocation. For each element added to the LinkedList, a new Node is created, resulting in a new memory ...
🌐
Medium
medium.com › javarevisited › arraylist-vs-linkedlist-in-java-a-deep-dive-into-performance-d3e119e9b452
ArrayList vs LinkedList in Java: A Deep Dive into Performance | by Thirupathi Pavan Sai | Javarevisited | Medium
September 20, 2025 - When working with Java Collections, developers often face a crucial decision: Should I use an ArrayList or a LinkedList? While both implement the List interface and provide similar functionalities, their internal structures result in significant performance differences depending on the use case.
🌐
DZone
dzone.com › data engineering › data › arraylist vs. linkedlist vs. vector
ArrayList vs. LinkedList vs. Vector
March 28, 2013 - arraylist add: 13265642 linkedlist ... 85768810 · the difference of their performance is obvious. linkedlist is faster in add and remove, but slower in get....
🌐
Medium
medium.com › @ashutosh-ceg › day-11-arraylist-vs-linkedlist-the-real-performance-difference-in-java-4e33f835dba0
Day 11 — ArrayList vs LinkedList: The Real Performance Difference in Java | by Ashutosh Kumar Tiwari | Medium
August 31, 2025 - Use ArrayList when you need: ✅ Fast random access ✅ Better cache performance ✅ Mostly appending at the end · Use LinkedList when you need: ✅ Frequent insertions/deletions in the middle ✅ Constant-time addition/removal from the beginning
🌐
LinkedIn
linkedin.com › pulse › arraylist-vs-linkedlist-helmut-siegel
ArrayList vs LinkedList
March 15, 2022 - If you are operating on a LinkedList via an Iterator, most operations become “cheap”, while if you are operating at indexes at arbitrary positions an ArrayList tends to perform better because you’re just doing an array access, and LinkedList requires seeking from the head or tail.
🌐
Baeldung
baeldung.com › home › java › java collections › java map › arraylist vs. linkedlist vs. hashmap in java
ArrayList vs. LinkedList vs. HashMap in Java | Baeldung
December 11, 2025 - In this article, we explored three common collection types in Java: ArrayList, LinkedList, and HashMap. We looked at their performance for adding, removing, and searching for items.
🌐
Coderanch
coderanch.com › t › 679527 › java › ArrayList-LinkedList-Sorting
ArrayList vs LinkedList Sorting (Performance forum at Coderanch)
My answer before trying it (which is not correct) A LinkedList is designed to be iterated through in order making sort an inefficient operation. So ArrayList will definitely be faster for your needs here. Also, sorting at the end is going to be faster because it lets the sort algorithm optimize.
🌐
The Coders Tower
coderstower.com › 2019 › 08 › 06 › arraylist-vs-linkedlist-sort-get-iteration
ArrayList vs LinkedList: Sort, Get and Iteration – The Coders Tower
September 20, 2020 - And finally, about looping, the best option is always to use the forEach. Still, ArrayList is faster. CAREFUL: do not use a normal for to iterate over a LinkedList, the performance is pretty bad.
🌐
GeeksforGeeks
geeksforgeeks.org › java › arraylist-vs-linkedlist-java
ArrayList vs LinkedList in Java - GeeksforGeeks
May 29, 2026 - ArrayList is based on a dynamic array, while LinkedList uses a doubly linked list · ArrayList provides faster random access, whereas LinkedList is efficient for frequent insertions and deletions
🌐
How to do in Java
howtodoinjava.com › home › collections framework › java arraylist › difference between linkedlist vs. arraylist in java
Difference between LinkedList vs. ArrayList in Java
January 13, 2023 - ArrayList provides get(int index), which directly finds the element at a given index location. It is of order O(1). LinkedList also provides get() method, BUT it first traverses all nodes to reach the correct node. It makes the performance variable.
🌐
Tech With KP
techwithkp.com › home › arraylist vs linkedlist in java (performance, internals & use cases)
ArrayList vs LinkedList in Java (Performance, Internals & Use Cases) - Tech With KP
January 7, 2026 - 📌 In benchmarks, ArrayList consistently outperforms LinkedList for general use. ... In memory-sensitive applications, LinkedList can become a performance bottleneck due to GC pressure.
🌐
Java67
java67.com › 2012 › 12 › difference-between-arraylist-vs-LinkedList-java.html
When to use ArrayList vs LinkedList in Java? [Answered] | Java67
3. Adding elements in ArrayList Adding an element in ArrayList is O(1) operation if it doesn't trigger re-size of Array, in which case it becomes O(log(n)), On the other hand, appending an element in LinkedList is O(1) operation, as it doesn't require any navigation. 4. Removing an element from a position In order to remove an element from a particular index e.g. by calling remove(index), ArrayList performs a copy operation which makes it close to O(n) while LinkedList needs to traverse to that point which also makes it O(n/2), as it can traverse from either direction based upon proximity.
🌐
Medium
medium.com › javarevisited › consider-linkedlist-in-java-2fed1b945b48
LinkedList vs ArrayList in Java | Javarevisited
September 19, 2021 - But for now, we can conclude that due to either of those effects ArrayList seems to perform substantially better than LinkedList using a more realistic setup with an actual GC running.