Creating Sequenced Collections, Sets, and Maps
Three interfaces introduced in JDK 21 represent collections with a defined encounter order. Each collection has a well-defined first element, second element, and so forth, up to the last element. They provide uniform APIs for accessing their first and last elements, and processing their elements in forward and reverse order.
SequencedCollection
A SequencedCollection is a collection type added in JDK 21 that represents a sequence of elements with a defined encounter order.
A SequencedCollection has first and last elements with the elements between them having successors and predecessors. A SequencedCollection supports common operations at either end, and it supports processing the elements from first to last and from last to first (such as, forward and reverse).