Skip to main content

Java List Interface and Implementations: Source-Level Overview

· One min read
Apache Wangye
Software developer and technical writer

List defines an ordered collection that permits positional access and usually allows duplicate elements. Implementations differ substantially in storage layout and performance.

ArrayList stores elements in a resizable array. Indexed reads are O(1), append is amortized O(1), and insertion or removal in the middle requires shifting elements. It is usually the default choice for general-purpose lists.

LinkedList stores nodes linked in both directions. Adding or removing through a known iterator position is constant time, but locating an index is O(n) and each element carries node overhead. It also implements Deque.

Vector is an older synchronized dynamic array. Its method-level synchronization rarely provides the compound-operation semantics an application needs. Prefer ArrayList with external synchronization or a purpose-built concurrent collection.

Iterators are generally fail-fast on structural modification, but this is a debugging aid rather than a concurrency guarantee. Choose an implementation according to measured access patterns, memory cost, concurrency model, and API semantics—not by assuming linked lists are automatically faster for insertion.

Page views: --

Total views -- · Visitors --