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)

🌐
GeeksforGeeks
geeksforgeeks.org › java › arraylist-vs-linkedlist-java
ArrayList vs LinkedList in Java - GeeksforGeeks
May 29, 2026 - ArrayList provides faster random access, whereas LinkedList is efficient for frequent insertions and deletions · Both are part of the Java Collections Framework and support generic data storage
Discussions

Is it worth swapping my code from ArrayList<Object> to LinkedList<Object>?

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions

  • You include any and all error messages in full - best also formatted as code block

  • You ask clear questions

  • You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.

If any of the above points is not met, your post can and will be removed without further warning.

Code is to be formatted as code block (old reddit/markdown editor: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.

Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.

Code blocks look like this:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.

If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.

To potential helpers

Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

More on reddit.com
🌐 r/learnjava
16
6
March 10, 2024
Can someone please explain the difference between List and ArrayList like I'm five?
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/javahelp
29
30
October 2, 2021
ArrayList vs LinkedList
Sure, copying array elements is fast in Java. But what what happens if the amount of data you have to copy to shift elements over becomes huge? And these shifts happen over and over again in your code? That’s when linked lists start to look more appealing ... I found this helpful. ... Also check out ArrayDeque. It's a double ended queue that can be used as a stack or queue or list. ArrayList is still better in most cases, but this is a good one to be familiar with. ... LinkedList ... More on reddit.com
🌐 r/learnjava
15
46
December 21, 2020
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
🌐
Reddit
reddit.com › r/learnjava › arraylist vs linkedlist
r/learnjava on Reddit: ArrayList vs LinkedList
December 21, 2020 - 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.
🌐
Scaler
scaler.com › home › topics › arraylist vs linkedlist in java
ArrayList vs LinkedList in Java - Scaler Topics
April 3, 2024 - In contrast, LinkedList offers O(1) time complexity for insertions and removals but O(n) for index-based access, as it requires traversing the list. When ArrayList is declared in the program the JVM(Java Virtual Machine) allocates a memory block of contiguous memory locations according to the size given in the declaration.
🌐
Baeldung
baeldung.com › home › java › java list › java arraylist vs linkedlist
Java ArrayList vs LinkedList | Baeldung
April 22, 2025 - So, it’s not possible to store more than 232 elements in a Java array and, consequently, in ArrayList. LinkedList, as its name suggests, uses a collection of linked nodes to store and retrieve elements.
🌐
Blogger
javarevisited.blogspot.com › 2012 › 02 › difference-between-linkedlist-vs.html
Difference between LinkedList and ArrayList in Java
The main difference between ArrayList and LinkedList is that ArrayList is implemented using a resizable array while LinkedList is implemented using doubly LinkedList. ArrayList is more popular among Java programmers than LinkedList as there ...
🌐
Medium
rameshfadatare.medium.com › difference-between-arraylist-and-linkedlist-in-java-ea609090c361
Difference Between ArrayList and LinkedList in Java | by Ramesh Fadatare | Medium
October 29, 2024 - import java.util.ArrayList; public class ArrayListStructureExample { public static void main(String[] args) { ArrayList<String> arrayList = new ArrayList<>(); arrayList.add("A"); arrayList.add("B"); arrayList.add("C"); System.out.println(arrayList); // Output: [A, B, C] } } ... On the other hand, LinkedList internally uses a doubly linked list.
Find elsewhere
🌐
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 - The LinkedList is a doubly linked list implementation in Java. Every object in the linkedlist is wrapped in a Node instance: transient Node<E> first; transient Node<E> last; private static class Node<E> { E item; Node<E> next; Node<E> prev; } The ArrayList has been implemented as a dynamically resizing array.
🌐
BeginnersBook
beginnersbook.com › 2013 › 12 › difference-between-arraylist-and-linkedlist-in-java
Difference between ArrayList and LinkedList in Java
Reason: ArrayList maintains index based system for its elements as it uses array data structure implicitly which makes it faster for searching an element in the list. On the other side LinkedList implements doubly linked list which requires the traversal through all the elements for searching ...
🌐
Medium
medium.com › javarevisited › consider-linkedlist-in-java-2fed1b945b48
LinkedList vs ArrayList in Java | Javarevisited
September 19, 2021 - Because ArrayList has to perform resizing operations once the inner container fills up while the LinkedList simply has to append a new node (the same operation regardless the size).
🌐
Java67
java67.com › 2012 › 12 › difference-between-arraylist-vs-LinkedList-java.html
When to use ArrayList vs LinkedList in Java? [Answered] | Java67
Being List implementation both ArrayList and LinkedList are ordered, the index-based and allows duplicate. Despite being from the same type of hierarchy there are a lot of differences between these two classes which makes them popular among Java interviewers.
🌐
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 - This article provides an in-depth analysis of both ArrayList and LinkedList, comparing their performance characteristics and use cases with detailed examples. ... An ArrayList in Java is a resizable array implementation of the List interface.
🌐
Unstop
unstop.com › home › blog › arraylist vs. linkedlist: key differences explained in detail
ArrayList Vs. LinkedList: Key Differences Explained in Detail
August 21, 2025 - Random access of elements is allowed in the ArrayList, so it performs very well where read operations are frequent or index-based access is required; otherwise, the performance is very poor. A dynamic array is used in this case to store the element array. LinkedList is an implementation of the List and Deque interfaces in Java that is modeled after a doubly linked list.
🌐
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.
🌐
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 doesn't have an array but a double-ended queue of mutually-connected elements instead. The first element points to the second one, which points to the third one, and so forth. Since this is a doubly-linked list, each element also points to its predecessor.
🌐
Java2Blog
java2blog.com › home › core java › java collections › difference between arraylist and linkedlist in java
Difference between ArrayList and LinkedList in java - Java2Blog
January 11, 2021 - ArrayList is implemented using array as internal data structure.It can be dynamically resized . LinkedList is implementation of list and deque interface.
🌐
Shiksha
shiksha.com › home › it & software › it & software articles › programming articles › arraylist vs. linkedlist
ArrayList vs. LinkedList - Shiksha Online
October 30, 2023 - ArrayList and LinkedList are linear data structure and are part of collection framework present in java.util packages. In this article, we will briefly discuss the difference between ArrayList and LinkedList in Java. ArrayList and LinkedList are linear data structure and are part of collection framework present in java.util packages.
🌐
DEV Community
dev.to › realnamehidden1_61 › differences-between-arraylist-and-linkedlist-in-java-37mn
Differences between ArrayList and LinkedList in Java - DEV Community
October 31, 2025 - A LinkedList, on the other hand, is like a chain of train cars — each car (called a node) holds data and a link to the next and previous cars. ... Insertion/deletion: Faster (O(1)) when adding/removing from the ends or middle (with a known reference) Memory usage: More — due to storing extra pointers (next and previous links) ... import java.util.ArrayList; public class ArrayListExample { public static void main(String[] args) { // Create an ArrayList of fruits ArrayList<String> fruits = new ArrayList<>(); // Add elements fruits.add("Apple"); fruits.add("Banana"); fruits.add("Cherry"); //
🌐
Medium
medium.com › @AlexanderObregon › the-difference-between-arraylist-and-linkedlist-in-java-c0c257db2fda
ArrayList vs LinkedList in Java: Differences | Medium
April 24, 2024 - In Java, ArrayList and LinkedList are two popular implementations of the List interface, which is a part of the Java Collections Framework. They are both used to store and manipulate collections of objects, but they have some key differences in terms of performance and underlying data structures.