The same task in Java 8 style and in modern style
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.
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.
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.
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
What are the LTS releases from Java 8 to 25, and how does the release cadence work?
What is a preview feature, and why should production code avoid it?
Name the most important changes between Java 8 and Java 11 for an application developer.
What changed between Java 11 and Java 17, and what tends to break when upgrading?
What are the headline features of Java 21 and Java 25?
Expected output
Java 8: [chai: few, samosa: many]
Java 16: [chai: few, samosa: many]
Receipt
items: 2
first order: Order[item=chai, qty=2]