RFR: 8316187: Modernize an example in StringTokenizer

Pavel Rappo prappo at openjdk.org
Fri Sep 15 18:06:11 UTC 2023


On Fri, 15 Sep 2023 16:20:15 GMT, Naoto Sato <naoto at openjdk.org> wrote:

> No need to create another PR for such changes IMO.
> Although it may be a bit odd to re-use the same variable names for different types, I might keep the original `myDate`/`myNumber` that aligns with other locations in the class descriptions.

Applied your suggestion and added as a new commit: f452189bfb6. Please double-check if that's what you meant.

Let me clarify the change to NumberFormat. Earlier in this PR, I said that `var` might still be relatively new to some. While true, in this case it's either `var` or the existing code, which applies to arrays, but not to `Iterable`s.

The reason is that unlike DateFormat, NumberFormat has two relevant overloads of `format`: one for `long` and another one for `double`. To keep the example type-agnostic, we should avoid explicit type in call to `format`. To that end, either `var` or avoiding the variable altogether would equally do.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/15716#issuecomment-1721650174


More information about the core-libs-dev mailing list