8158312: Update String.join example code to use List convenience factory methods

Reviewed-by: lancea, smarks
This commit is contained in:
Joe Darcy 2016-05-31 19:13:21 -07:00
parent 4300a5a412
commit 77859dc5ca

View File

@ -2424,15 +2424,12 @@ public final class String
*
* <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>