Command Palette

Search for a command to run...

Back to the lesson: Topic 11.6 — What Changed from Java 8 to Java 25
Core Java · Example 3 of 3 Java 21+

What Java 21 adds

Java ships a new version every six months, and every two years one becomes a long-term support (LTS) release: 8, 11, 17, 21 and 25. This topic maps the important language, library, JVM and removal changes in each release from Java 8 to Java 25, so you can read any codebase, know what version a feature needs, and plan an upgrade.

Change the code and press Run (Ctrl+Enter). Try to predict the output first, then break it on purpose and read the error. Your edits are saved and match the lesson page.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Modernise this Java 8 idea: sort students by marks (highest first, ties by name) and print name (marks) joined by commas, using a record, var, Comparator combinators and Stream.toList(). Use Ravi 81, Asha 92, Meera 81.

02

Write one small program that uses a feature from Java 8, 11, 16, 17 and 21, label each in a comment, and state the minimum Java version needed to compile it.

03

Write a program that prints the running JDK's feature release number, java.version and java.vendor. Which API gives the feature number, and since when?

Explain it without notes

01

What are the LTS releases from Java 8 to 25, and how does the release cadence work?

02

What is a preview feature, and why should production code avoid it?

03

Name the most important changes between Java 8 and Java 11 for an application developer.

04

What changed between Java 11 and Java 17, and what tends to break when upgrading?

05

What are the headline features of Java 21 and Java 25?

What Java 21 adds Java 21+
This example needs Java 21+. The in-browser compiler is Java 17: install JDK 21 or newer and run it with "java Main.java".

Expected output

first: Asha, last: Meera
reversed view: [Meera, Ravi, Asha]
after addFirst: [Kabir, Asha, Ravi, Meera]
first entry: chai=20, last entry: dosa=80
Math.clamp(150, 0, 100) = 100
StringBuilder.repeat: ababab
circle r=1.0
square side=2.0