Open Menu dzosoft
Close Menu dzosoft



Hiding your face is not a solution!

Publish perfectly-optimized content in 1-click


Java 21 includes ordered collections and string templates

March 13, 2023


Java 21 includes ordered collections and string templates

The next LTS release of Oracle's Java SE is beginning to take shape. JDK version 21 will include some features such as ordered collections and string templates.

Little by little the contours of the next implementation of Java SE LTS are taking shape. Scheduled for September, Java Development Kit (JDK) 21 will include ordered collections and string templates, among other things. Even though as of March 3, 2023, the JDK 21 release page does not yet mention any features, two Java improvement proposals covering these two features have already been designated for the next iteration.


Ordered collections


Ordered collections introduce interfaces to represent collections in a defined encounter order. Each collection has a well-defined set, from the first to the last element. Uniform APIs are provided to accept first and last items and process items in reverse order. The proposal aims to address a situation where the Java collections framework lacks a collection type to represent a sequence of elements with a defined encounter order.

A uniform set of operations that apply to these collections is also lacking. These shortcomings were problematic and aroused criticism. The proposal plans to define sequencing interfaces for collections, sets and maps, and integrate them into the existing hierarchy of collection types. All of these add-on methods have default implementations.


The String templates


String templates, which will be released in preview, complement Java's existing string literals and text blocks by coupling literal text with expressions and built-in processors to produce specialized results. This API should simplify the writing of Java programs by making it easier to express strings that include values ​​calculated at runtime. It promises to improve the readability of expressions, strengthen program security, retain flexibility, and simplify the use of APIs that accept strings written in languages ​​other than Java. The goal is also the development of non-string expressions derived from the combination of literal text and embedded expressions.

As an LTS release, JDK 21 will receive five years of Premier support and extended support until September 2031. The current LTS release is JDK 17, released in September 2021. Non-LTS releases, such as the JDK release 20 scheduled for March 21 and the current JDK 19 release, only get six months of Premier support and no extended support. Every six months, Oracle releases new versions of the Java SE implementation. Other possible JDK 21 features include all JDK 20 incubation and preview features, such as Scoped values, Record patterns, and Virtual threads. Universal generics and asynchronous stack tracking VM API might also be included in future JDK.
Leave comment

Save nickname and email in this browser for the next time.

close publicity