java.util · java.base · since Java 1.2

ListIterator

declaration
public interface ListIterator<E> extends Iterator<E>

A bidirectional cursor over a List that can also insert, replace, and remove at the current position — the one place LinkedList editing beats ArrayList.

Key methods

boolean hasNext() / hasPrevious()Traversal in either direction.
E next() / E previous()Advance / retreat, returning the crossed element.
int nextIndex() / previousIndex()Indices of the elements the cursor sits between.
void set(E e)Replace the last element returned by next/previous.
void add(E e)Insert before the element that next() would return.
void remove()Remove the last element returned (CME-safe).