RFR - JDK-8203444 String::formatted (Preview)

Florian Weimer fweimer at redhat.com
Tue May 21 15:44:28 UTC 2019

* Jim Laskey:

> All discussion is valid. I agree the ambiguity is tricky, but can be
> resolved by using explicit locale.
> Example:
> 	"%s".formatted(Locale.getDefault(), Locale.JAPAN);
> This guarantees the "public String formatted(Locale l,
> Object... args)" form is chosen with the second Locale as an argument.

There is also the cognitive overhead.  I think the key question is
whether this is so bad:

  String.format(Locale.US, """
  """, Locale.JAPAN);

Then perhaps we wouldn't need the formatted method which takes a Locale


More information about the compiler-dev mailing list