Skip to content
Sahithyan's S2
Sahithyan's S2 — Program Construction

ArrayList

A resizable array implementation of the List interface from the Java Collections Framework. Allows dynamic resizing and provides methods to manipulate the stored elements. Supports a generic to hint the type of elements. Cannot hold primitive types, like int, char, etc. Wrapper classes are needed.

By default, an ArrayList has an initial capacity of 10 elements. When the number of elements exceeds this capacity, the ArrayList automatically increases its capacity by approximately 50%. Each element has a memory overhead of 24 bytes.

Complexity

OperationTimeSpace
Inserting Element in ArrayListO(1)O(1)O(n)O(n)
Removing Element from ArrayListO(n)O(n)O(1)O(1)
Traversing Elements in ArrayListO(n)O(n)O(n)O(n)
Replacing Elements in ArrayListO(1)O(1)O(1)O(1)