mirror of
https://github.com/openjdk/jdk.git
synced 2026-06-05 02:02:31 +00:00
8158312: Update String.join example code to use List convenience factory methods
Reviewed-by: lancea, smarks
This commit is contained in:
parent
4300a5a412
commit
77859dc5ca
@ -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>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user