The method String.formatted()
is a new feature in Java 13 introduced together with text blocks and can be used instead of String.format(templateString, replacement1, replacement2, ...)
.
The compiler issues a jarring warning when using this method because it might be removed again in future versions (but it could also stay).
Is there a way to specifically disable this compiler warning without annotating each usage with @SuppressWarnings("removal")
or disabling all deprecation warnings as java compiler parameter?
You can add
-Xlint:-removal
parameter tojavac
command line and instead of warning you will get a note message per class:I don't think there is an option to specify this just for
String.formatted()
, it's global.