changeset 16609:b87b1112263f

8158312: Update String.join example code to use List convenience factory methods Reviewed-by: lancea, smarks
author darcy
date Tue, 31 May 2016 19:13:21 -0700
parents a3e5bc744553
children 1003b17156f3
files src/java.base/share/classes/java/lang/String.java
diffstat 1 files changed, 3 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/lang/String.java	Tue May 31 21:27:28 2016 -0400
+++ b/src/java.base/share/classes/java/lang/String.java	Tue May 31 19:13:21 2016 -0700
@@ -2424,15 +2424,12 @@
      *
      * <blockquote>For example,
      * <pre>{@code
-     *     List<String> strings = new LinkedList<>();
-     *     strings.add("Java");strings.add("is");
-     *     strings.add("cool");
+     *     List<String> strings = List.of("Java", "is", "cool");
      *     String message = String.join(" ", strings);
      *     //message returned is: "Java is cool"
      *
-     *     Set<String> strings = new LinkedHashSet<>();
-     *     strings.add("Java"); strings.add("is");
-     *     strings.add("very"); strings.add("cool");
+     *     Set<String> strings =
+     *         new LinkedHashSet<>(List.of("Java", "is", "very", "cool"));
      *     String message = String.join("-", strings);
      *     //message returned is: "Java-is-very-cool"
      * }</pre></blockquote>