The best resource is straight from the official API:

The size, isEmpty, get, set, iterator, and listIterator operations run in constant time. The add operation runs in amortized constant time, that is, adding n elements requires O(n) time. All of the other operations run in linear time (roughly speaking). The constant factor is low compared to that for the LinkedList implementation.

Answer from brian_d on Stack Overflow
🌐
Quora
quora.com › Whats-the-complexity-of-set-index-element-of-an-array-list-in-Java
What's the complexity of 'set (index, element)' of an array list in Java? - Quora
Time complexity: O(1) — constant time. ... ArrayList stores elements in a contiguous Object[] array. The set(index, element) operation checks bounds, then assigns the new element into the array slot and returns the old value.
Discussions

Why is the add(index, element) time complexity not constant in Java for array lists?

For array lists, you would have to move all elements to adjacent positions when you insert at an index. So it takes linear time ( more the number of elements already in the list, more time it takes to move them all ).

Also Java has nothing to do with time complexities of a data structure. It is universal.

More on reddit.com
🌐 r/learnjava
8
2
June 1, 2020
Time complexity for java ArrayList - Stack Overflow
Is ArrayList an array or a list in java? what is the time complexity for the get operation, is it O(n) or O(1)? More on stackoverflow.com
🌐 stackoverflow.com
Analyzing time complexity of Java methods
Their time complexities are almost always specified in the Javadoc documentation you can find online, for example here's ArrayList docs: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/ArrayList.html You can find Java source code on github. For example, here's the addAll method of an ArrayList: https://github.com/openjdk/jdk/blob/fe0544f8a7db5bf0e93313e16b54b31bcdff946a/src/java.base/share/classes/java/util/ArrayList.java#L669 You can also access these locally if your JDK came with sources or by installing java-{VERSION}-openjdk-src package (RHEL/Fedora) if it didn't. Or just open up your IDE, call the method and then use the "Go to Definition" funcitonality, it'll probably first show the decompiled version, but I think IntelliJ also offers to download sources automatically. More on reddit.com
🌐 r/learnprogramming
12
1
August 23, 2022
What is the complexity of contains method of HashSet?
It is O(1) in practice, but in the very very worst case (when you have objects with a broken hash function) it is O(n). It can be considered O(m) with m being the size of your object you're inserting: hash function calculation scales linearly with object size. But that's insignificant in practice, and not relevant when talking about Sets and Collections. More on reddit.com
🌐 r/java
33
3
December 9, 2021
🌐
Cisc3130fa24
cisc3130fa24.github.io › handouts › ArrayList-complexity.html
time complexity of ArrayList operations
Suppose that list refers to an ArrayList<E>, element is a variable of type E, and index is a random int in the range [0, list.size()). Suppose that iter is an Iterator<E> obtained via list.iterator(). It is possible that iter has been moved forward using iter.next(); that is, the cursor is ...
🌐
YourBasic
yourbasic.org › algorithms › time-complexity-arrays
Time complexity of array/list operations [Java, Python] · YourBasic
Warning: This code has quadratic time complexity. It runs in time Θ(n2), where n is the initial length of the list a. This means that the program is useful only for short lists, with at most a few thousand elements. ... To avoid this type of performance problems, you need to know the difference between constant and linear time list operations. The following ArrayList methods operate on a subset of the elements, but still have time complexity that depends on the size n of the list.
🌐
Baeldung
baeldung.com › home › java › java collections › time complexity of java collections
Time Complexity of Java Collections | Baeldung
September 24, 2025 - Usually, when we talk about time complexity, we refer to Big-O notation. Simply put, the notation describes how the time to perform the algorithm grows with the input size. Useful write-ups are available to learn more about Big-O notation theory and practical Java examples. Let’s start with a simple list, which is an ordered collection. Here we’ll look at a performance overview of the ArrayList...
🌐
Carnegie Mellon University
cs.cmu.edu › ~mrmiller › 15-121 › Slides › 09-BigO-ArrayList.pdf pdf
Big O & ArrayList 15-121 Fall 2020 Margaret Reid-Miller
September 24, 2020 - Time(n) = 3n = O(3n), not O(2n)! ... A followed by B. • Then the overall complexity of the algorithm is
Find elsewhere
🌐
DEV Community
dev.to › jhonifaber › choosing-the-right-java-collection-5750
Java Collections: From Lists to Maps with Time Complexity in Mind - DEV Community
August 7, 2025 - When you need to ensure no duplicates in your collection, use a Set. Time Complexity (HashSet):
🌐
Luke Du
blog.duyidong.com › 2020 › 07 › 20 › data-structure-and-time-complexity
Time Complexity of Java Collections - Luke.Du's blog
December 19, 2022 - get() – searching for an element takes O(n) time. remove(element) – to remove an element, we first need to find it. This operation is O(n). remove(index) – to remove an element by index, we first need to follow the links from the beginning; ...
🌐
Medium
yogeshkkhichi.medium.com › time-and-space-complexity-of-collections-5a00c7b1d32b
Time and Space Complexity of Collections | by Yogesh Kumar | Medium
November 17, 2020 - ... Hashset is implemented using ... in a set are sorted, but the add, remove, and contains methods has time complexity of o(log (n))....
🌐
University of Pennsylvania
cis.upenn.edu › ~cis110 › 16sp › lectures › 43bArrayList.pdf pdf
ArrayLists & List Computational Complexity
n Supports constant time for · q insertion at the “end” of the list using · void add(E element) q deletion from the “end” of the list using · E remove(int index) q access to any element of the list using · E get(int index) q changing value of any element of the list using · E set(int index, E element) 8 · List Operations on an ArrayList<E> (cont.) What is the computational complexity for the ·
🌐
Mysweetindulgence
mysweetindulgence.com › home › other › what is the time complexity of arraylist in java?
What is the time complexity of ArrayList in Java? – MSI
The size of an empty ArrayList is zero. Big O notation is a mathematical notation that describes the limiting behavior of a function when the argument tends towards a particular value or infinity. The letter O is used because the growth rate of a function is also referred to as the order of the function. ... 3 Answers. According to Python wiki: Time complexity, set is implemented as a hash table.
🌐
GitHub
gist.github.com › psayre23 › c30a821239f4818b0709
Runtime Complexity of Java Collections · GitHub
I have to build my Programs in a way that saves time! ... Thankyou! Only a small mistake that I think is LinkedList remove is O(N) not O(1) because it first needs to find the node before deleting it. ... To the point. Thanks man! ... @Barry36 nope, it's O(M+N) where M = array size (the ArrayList) and N = collection size (the function argument Collection).
🌐
LeetCode
leetcode.com › problems › insert-delete-getrandom-o1 › discuss › 357236 › beat-95-with-explanation-of-this-ArrayList-operation-time-complexity › 324681
beat 95% with explanation of this ArrayList operation time ...
August 12, 2019 - Can you solve this real interview question? Insert Delete GetRandom O(1) - Implement the RandomizedSet class: * RandomizedSet() Initializes the RandomizedSet object. * bool insert(int val) Inserts an item val into the set if not present. Returns true if the item was not present, false otherwise.
🌐
Medium
bikashdubey42.medium.com › arraylist-vs-linkedlist-in-java-633e68f49d22
Time Complexity of Java Collections API | by Bikash Dubey | Medium
November 17, 2020 - Basically this is the limitation of the array is that the size of the array is predefined and fixed. There are multiple ways to solve this problem. But In this article, we will talk about the difference between two classes which are implemented to solve this problem named as ArrayList and LinkedList.
🌐
University of Pennsylvania
cis.upenn.edu › ~cis110 › 15sp › lectures › 43bArrayList.pdf pdf
ArrayLists and List Computational Complexity
n Supports constant time for · q insertion at the “end” of the list using · void add(E element) q deletion from the “end” of the list using · E remove(int index) q access to any element of the list using · E get(int index) q changing value of any element of the list using · E set(int index, E element) 8 · List Operations on an ArrayList<E> (cont.) What is the computational complexity for the ·
🌐
Quizlet
quizlet.com › 544419855 › time-complexity-flash-cards
Time Complexity Flashcards | Quizlet
ArrayList get( ) Time Complexity · O(1) know index, don't have to seek · ArrayList set( ) Time Complexity · O(1) know index, don't have to seek · ArrayList remove( ) Time Complexity · O(n) have to shift backing array · ArrayList indexOf( ) Time Complexity ·
🌐
Chalmers University
cse.chalmers.se › edu › year › 2016 › course › TDA547_Object_Oriented_Programming › lect09.html
Lecture 10
The conclusion is that the insertion and the removal of random elements has complexity O(n) while the access to random elements remains constant O(1). The array list is a useful data structure when a random acceess is frequently needed while the insertions and deletions are rare.
🌐
Scribd
scribd.com › document › 879405794 › AP-CSA-Unit-7-Saiyana-Uthayasegar
ArrayList Add Time Complexity Explained | PDF | Time Complexity | Control Flow
The 'set' method replaces an element at a specified index with a new element in constant time (O(1)), as it does not involve shifting elements. In contrast, adding or removing elements at arbitrary positions may require shifting subsequent elements, ...