Session

Robust and flexible string templates in Java

Java 21 was packed with exciting and groundbreaking innovations. In the shadow of the very present topics, string templates were relatively surprisingly introduced as a preview feature and are also included again in OpenJDK 22. They allow expressions to be embedded in string literals and text blocks. Thanks to self-definable template processors, this procedure is even customizable.

We discuss the use of string templates, look at the advantages but also the limitations. By creating our own template processors, we can validate and transform the embedded expressions and ultimately create any Java objects such as JSON documents or SQL result sets from Java strings. You can incorporate these ideas into your daily work and try out string interpolation now. Even though there will initially be no string templates in Java 23, they will soon return.

Falk Sippach

embarc

Darmstadt, Germany

Actions

Please note that Sessionize is not responsible for the accuracy or validity of the data provided by speakers. If you suspect this profile to be fake or spam, please let us know.

Jump to top