JAVA 21 Features

Fth Feyza
6 min readOct 23, 2023

This article is about the simple introduction of Java 21 and its new features.
Java 21 has been released on 19-Sep-2023.
Java 21 is the next long-term support (LTS) release of Oracle’s standard Java implementation.

The 15 JEPs delivered with Java 21 :

1. JEP 430: String Templates (Preview)

String templates are a preview feature in JDK 21.
Simplifies the writing of Java programs by making it easy to express strings that include values computed at run time.
It attempts to bring more reliability and better experience to String manipulation to avoid common pitfalls that can sometimes lead to undesirable results, such as injections.
Now you can write template expressions and render them out in a String.
Simplifies the use of APIs that accept strings written in non-Java languages (e.g., SQL, XML, and JSON).

Exemple:
String name = “Fatih”
String greeting = “Hello \{name}”;

2. JEP 431: Sequenced Collections

It basically improves our experience with Collections and Maps.
With Sequenced Collections, you can easily select the first or last element.
And also you can easily add first or last element. Now you have reverse function in Sequenced Collections.
It really bother Java developers that hard to manipulate in Collection. Now you can easily manipulate…

--

--