Class SequencedCollectionsExamples

java.lang.Object
net.jrodolfo.java_evolution.java21.SequencedCollectionsExamples

public class SequencedCollectionsExamples extends Object
Demonstrates sequenced collections, introduced in Java 21.

Java had many ordered collections before Java 21, but there was no shared API for first element, last element, or reversed views. Generic code had to know whether it was dealing with a List, deque, ordered set, or ordered map.

Sequenced collection interfaces give encounter-ordered data structures a common vocabulary. The reversed() operation returns a reversed view rather than requiring callers to make a defensive copy just to look at the same data from the other direction.