Java Reference ยท Language Features by Version
Java 22 to 25 features
What arrived in Java 22, 23, 24 and 25 (LTS): unnamed variables, simple main, scoped values, stream gatherers, module imports and flexible constructors.
Java 22 to 25 finishes several long-running efforts: unnamed variables, the foreign function and memory API, stream gatherers, the class-file API, scoped values, module imports, compact source files and flexible constructor bodies all went from preview to final in this window. Java 25 (September 2025) is the Long-Term Support release that bundles them, and it is the version our runner uses.
Features are listed with the release in which they became final (usable without --enable-preview). Features that are still preview in Java 25 are marked clearly and shown read-only, because the runner does not pass --enable-preview.
// Java 25: no class, no "public static", java.base is imported for you void main() { IO.println("Hello from Java " + Runtime.version().feature()); }
Try it
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with IO.readln() or a Scanner), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with IO.readln() or a Scanner), it gets the next line from this box.
Release by release
Java 22 (March 2024)
- Unnamed variables and patterns (
_) are final (unnamed variables). - Foreign Function & Memory API (
java.lang.foreign) is final: call native code and manage off-heap memory safely, replacing most JNI. - Launch multi-file source programs:
java Main.javacan compile other source files it needs from the same directory. - Preview in 22: statements before
super(...), string templates (withdrawn in 23), implicit classes, stream gatherers, class-file API, structured concurrency, scoped values.
Java 23 (September 2024)
- Markdown documentation comments (
///) are final (Javadoc). - Generational mode becomes the default for ZGC.
- Previews continue: primitive types in patterns, module import declarations, flexible constructor bodies and more.
Java 24 (March 2025)
- Stream Gatherers (
Stream.gather,java.util.stream.Gatherers) are final. - Class-File API (
java.lang.classfile) is final: reading and writing.classfiles without a third-party library. - Ahead-of-time class loading and linking to cut start-up time.
- The Security Manager is permanently disabled.
- Virtual threads no longer get pinned by
synchronizedblocks in most cases. - Post-quantum algorithms: ML-KEM and ML-DSA.
Java 25 (September 2025, LTS)
- Compact source files and instance
mainmethods are final (simple main);java.lang.IOoffersIO.printlnandIO.readln. - Module import declarations:
import module java.base;imports every package a module exports. - Flexible constructor bodies are final: statements may appear before
super(...)/this(...). - Scoped values are final.
- Compact object headers (smaller objects) and generational Shenandoah GC are product features; AOT cache improvements; a key derivation function API.
- Still preview in 25: structured concurrency (
StructuredTaskScope, fifth preview), primitive types in patterns,StableValueand PEM encodings of cryptographic objects. They need--enable-previewon bothjavacandjava.
Usage notes
- Flexible constructors allow validation and argument conversion before
super(...), but those statements cannot readthis, call instance methods or use instance fields. They may assign fields that have no initializer in the same class. _cannot be read. In acatch (SomeException _)or lambda(_, b) -> bit just means "ignored". Before Java 9_was a legal identifier; today using it as a name is an error.- Scoped values are immutable inside a scope and inherited by child tasks, which makes them safer than
ThreadLocalfor virtual threads. Gatherers.windowFixed(n)keeps a final partial window;windowSliding(n)produces nothing if the stream is shorter thann.- Dates can be misremembered: JEP numbers and release lists change while features are in preview. Check the release notes of your JDK when in doubt.