Package modernfeatures.java21
Class SequencedCollectionDemo
java.lang.Object
modernfeatures.java21.SequencedCollectionDemo
Demonstrates SequencedCollection in Java 21 using an ArrayList.
SequencedCollection is a new interface introduced in Java 21 that ensures a predictable order for collection elements. It provides methods to access the first and last elements, as well as a reversed view.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
SequencedCollectionDemo
public SequencedCollectionDemo()
-
-
Method Details
-
main
Main method to demonstrate usage of SequencedCollection. It creates a sequenced collection, adds elements, retrieves first and last elements, and prints a reversed view of the collection.- Parameters:
args
- command-line arguments (not used)
-