Integrated: 8316187: Modernize examples in StringTokenizer and {Date,Number}Format

Pavel Rappo prappo at openjdk.org
Sat Sep 16 07:54:56 UTC 2023


On Wed, 13 Sep 2023 12:39:00 GMT, Pavel Rappo <prappo at openjdk.org> wrote:

> This modernizes an example to use the extended for-statement introduced in JDK 1.5.
> 
> I understand that StringTokenizer is a legacy class. But legacy or not, a class shouldn't promote older constructs when newer fit better. Especially when advising on preferred alternatives to itself.
> 
> That said, I wouldn't go as far as to use `var` anywhere in that example: JDK 10, which introduced `var`, might still be relatively new to some. Nor would I inline the call to `String.split` in the for-statement to dispense with the `String[] result` variable: I reckon it's good for a reader unfamiliar with `String.split` to see the type it returns.
> 
> Perhaps one additional thing to ponder is this: we could either add `@see` to point to `String.split` or make the whole example a `@snippet`, which `@link`s code to the definition of `String.split`.

This pull request has now been integrated.

Changeset: c92bdb0e
Author:    Pavel Rappo <prappo at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/c92bdb0e917e1251c0c2ef6b873df702b816c1f4
Stats:     7 lines in 3 files changed: 0 ins; 0 del; 7 mod

8316187: Modernize examples in StringTokenizer and {Date,Number}Format

Reviewed-by: naoto

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

PR: https://git.openjdk.org/jdk/pull/15716


More information about the core-libs-dev mailing list