String interpolation in Java 14 or 15
To my knowledge, there are no updates in the standard java libraries regarding such kind of string formatting.
In other words: you are still "stuck" with either using String.format()
and its index based substitution mechanism, or you have to pick some 3rd party library/framework, such as Velocity, FreeMarker, ... see here for an initial overview.
There is something slightly closer; an instance version of String::format
, called formatted
:
String message = "Hi, %s".formatted(name);
It is similar to String::format
, but is more friendly to use in chained expressions.