Package net.jrodolfo.java_evolution.java21
package net.jrodolfo.java_evolution.java21
Examples for features introduced in Java 21.
Java 21 is an LTS release and a major modern-Java milestone. It finalized virtual threads for scalable blocking code, record patterns for deconstructing data, and pattern matching for switch for type-based dispatch. It also introduced sequenced collections as a final Collections Framework feature, included preview work for unnamed patterns/variables, scoped values, and structured concurrency, and added the Key Encapsulation Mechanism API.
-
ClassDescriptionDemonstrates pattern matching for switch, finalized in Java 21.Closed command hierarchy used to demonstrate exhaustive switch handling.Restarts a service.Starts a service.Stops a service.Demonstrates record patterns, finalized in Java 21.Point record used by the nested deconstruction example.Rectangle record made of two points.Demonstrates sequenced collections, introduced in Java 21.Captures direct observations from
SequencedMap.Captures direct observations fromSequencedCollection.Captures the state of a collection and its reversed view after a mutation.Demonstrates unnamed patterns and variables as a Java 21 preview feature.Line record used by the unnamed record-pattern example.Point record used by the unnamed record-pattern example.Demonstrates virtual threads, finalized in Java 21.