Unnamed Variables & Patterns
An underscore marks a variable or pattern component the program does not read.
Preview in Java 21 (JEP 443).
OpenJDK JEP 456 (leaves JavaMastery)
Curriculum file: versions7Java22Unnamed.java
JDK 22 · JSR 397
JDK 22 is Java SE 22, JSR 397, generally available on 19 March 2024. Unnamed variables and the foreign function and memory API become permanent. Stream gatherers, the class-file API, statements before super(...), and string templates are previews. Structured concurrency and scoped values are still previews.
An underscore marks a variable or pattern component the program does not read.
Preview in Java 21 (JEP 443).
OpenJDK JEP 456 (leaves JavaMastery)
Curriculum file: versions7Java22Unnamed.java
A constructor may run statements before super(...) or this(...). Those statements cannot use the object under construction. This is a preview.
Final in Java 25 as flexible constructor bodies (JEP 513).
The compact-program preview continues. A source file can still omit the usual class declaration.
First preview in Java 21 (JEP 445). Final in Java 25 (JEP 512).
String templates are previewed a second time. They are not finalized in this release.
First preview in Java 21 (JEP 430). They do not appear in the JDK 23, JDK 24, or JDK 25 feature lists.
Java programs can call native code and use off-heap memory through a standard API, without JNI for the common cases.
Incubated in Java 17 and Java 18. Preview in Java 19, Java 20, and Java 21.
A gatherer is a preview intermediate stream operation that can do more than the built-in operations.
Second preview in Java 23 (JEP 473). Final in Java 24 (JEP 485).
OpenJDK JEP 461 (leaves JavaMastery)
Related reading: Streams and Optional
A preview API parses, generates, and transforms class files. It is not final.
Final in Java 24 (JEP 484).
Structured concurrency is previewed a second time.
Still a preview in Java 25 (JEP 505).
OpenJDK JEP 462 (leaves JavaMastery)
Related reading: Concurrency
Scoped values are previewed a second time.
Final in Java 25 (JEP 506).
OpenJDK JEP 464 (leaves JavaMastery)
Related reading: Concurrency
The Vector API incubates a seventh time.
Still incubating in Java 25.
G1 can pin individual regions during native calls instead of disabling garbage collection for the whole heap.
OpenJDK JEP 423 (leaves JavaMastery)
Related reading: JVM and memory
The java launcher can run a program that is split across more than one source file, without a separate compile step.
String templates are still a preview. Nothing in Java 23, 24, or 25 turns them into a final feature.
Sources. General availability, JSR 397, and the JEP list: OpenJDK JDK 22. OpenJDK JDK 22 (leaves JavaMastery)