CollectionsLists
Overview
Ordered, index-based collections with comparison benchmarks and structural trade-offs
The List<E> interface represents an ordered sequence of elements where duplicates and null values are allowed. Elements can be inserted or accessed by their integer index.
List Implementations Comparison
| Class | Internal Structure | Access (get(i)) | Append (add) | Head Insert/Delete | Thread Safe |
|---|---|---|---|---|---|
ArrayList | Contiguous dynamic array | O(1) | O(1) amortized | O(n) | No |
LinkedList | Doubly-linked discrete nodes | O(n) | O(1) | O(1) | No |
Vector | Synchronized dynamic array | O(1) | O(1) amortized | O(n) | Yes (Locking) |
Stack | Extends Vector (LIFO) | O(1) | O(1) | O(1) (top) | Yes (Locking) |