The Java Collections Framework has historically lacked a collection type that represents a sequence of elements with a defined ordering, along with uniform operations that apply across such collections. These gaps have been a continual source of problems and complaints. These deficiencies have been resolved with the introduction of Sequenced Collections in JDK 21.
Sequenced Collections (JEP 431) is the first new abstraction to be added to Collections since the introduction of Streams in JDK 8. Although the concept of encounter order has always been present in Collections, it has never had an explicit interface type in the API, and thus there has never been a place to define a common set of operations that apply to ordered collections. New operations include addition, retrieval, and removal of elements at either end of the collection, and the ability to view, iterate, and stream elements in reverse order.
Another significant feature is the rehabilitation of LinkedHashSet and its sibling LinkedHashMap. LinkedHashSet is like an ordered Set or a List with unique elements. However, the operations on LinkedHashSet are glaringly deficient. It is a concrete class with no corresponding interface, conflicting with the idiom of programming to the interface. Sequenced Collections solves all of these problems.
Attendees will learn about the new enhancements to the Collections Framework and how they can improve and streamline their code using the new Sequenced Collections APIs.
Stuart Marks
Stuart Marks is the JDK Core Libraries project lead in the Java
Platform Group at Oracle. His areas of expertise include Collections,
Lambdas, and Streams. As his alter ego "Dr Deprecator" he also works
on Java's deprecation mechanism. Stuart previously worked on JavaFX
and Java ME at Sun Microsystems. He has over thirty years of software
platform product development experience in the areas of window
systems, interactive graphics, payments, and mobile and embedded
systems. Stuart holds a Master's degree in Computer Science and a
Bachelor's degree in Electrical Engineering from Stanford University.