JEP! 431: Sequenced Collections

Java’s collections frameworkarrow-up-right lacks a collection type that represents a sequence of elements with a defined encounter order. It also lacks a uniform set of operations that apply across such collections.

For example, List and Deque both define an encounter order but their common supertype is Collection, which does not. Similarly, Set does not define an encounter order, and subtypes such as HashSet do not define one, but subtypes such as SortedSet and LinkedHashSet do.

Before JDK 21, ordered collections had inconsistent APIs; now Java finally has one common vocabulary for ‘first’, ‘last’, and ‘reversed’ RUN :

Last updated