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

Reviewed-by: naoto
This commit is contained in:
Pavel Rappo 2023-09-16 07:51:34 +00:00
parent 8f46abc938
commit c92bdb0e91
3 changed files with 7 additions and 7 deletions
src/java.base/share/classes/java

@ -85,8 +85,8 @@ import sun.util.locale.provider.LocaleServiceProviderPool;
* <blockquote>
* {@snippet lang=java :
* DateFormat df = DateFormat.getDateInstance();
* for (int i = 0; i < myDate.length; ++i) {
* output.println(df.format(myDate[i]) + "; ");
* for (Date myDate : dates) {
* output.println(df.format(myDate) + "; ");
* }
* }
* </blockquote>

@ -82,8 +82,8 @@ import sun.util.locale.provider.LocaleServiceProviderPool;
* <blockquote>
* {@snippet lang=java :
* NumberFormat nf = NumberFormat.getInstance();
* for (int i = 0; i < myNumber.length; ++i) {
* output.println(nf.format(myNumber[i]) + "; ");
* for (var myNumber : numbers) {
* output.println(nf.format(myNumber) + "; ");
* }
* }
* </blockquote>

@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -83,8 +83,8 @@ import java.lang.*;
* method can be used to break up a string into its basic tokens:
* <blockquote><pre>
* String[] result = "this is a test".split("\\s");
* for (int x=0; x&lt;result.length; x++)
* System.out.println(result[x]);
* for (String r : result)
* System.out.println(r);
* </pre></blockquote>
* <p>
* prints the following output: