jdk/src/java.base/share/classes/java/lang/String.java
changeset 38765 b64f3ec3420e
parent 37723 1b9abe91485d
child 38786 8e7b0ac05815
equal deleted inserted replaced
38764:181a08b094a4 38765:b64f3ec3420e
  2422      * {@code CharSequence elements} joined together with a copy of the
  2422      * {@code CharSequence elements} joined together with a copy of the
  2423      * specified {@code delimiter}.
  2423      * specified {@code delimiter}.
  2424      *
  2424      *
  2425      * <blockquote>For example,
  2425      * <blockquote>For example,
  2426      * <pre>{@code
  2426      * <pre>{@code
  2427      *     List<String> strings = new LinkedList<>();
  2427      *     List<String> strings = List.of("Java", "is", "cool");
  2428      *     strings.add("Java");strings.add("is");
       
  2429      *     strings.add("cool");
       
  2430      *     String message = String.join(" ", strings);
  2428      *     String message = String.join(" ", strings);
  2431      *     //message returned is: "Java is cool"
  2429      *     //message returned is: "Java is cool"
  2432      *
  2430      *
  2433      *     Set<String> strings = new LinkedHashSet<>();
  2431      *     Set<String> strings =
  2434      *     strings.add("Java"); strings.add("is");
  2432      *         new LinkedHashSet<>(List.of("Java", "is", "very", "cool"));
  2435      *     strings.add("very"); strings.add("cool");
       
  2436      *     String message = String.join("-", strings);
  2433      *     String message = String.join("-", strings);
  2437      *     //message returned is: "Java-is-very-cool"
  2434      *     //message returned is: "Java-is-very-cool"
  2438      * }</pre></blockquote>
  2435      * }</pre></blockquote>
  2439      *
  2436      *
  2440      * Note that if an individual element is {@code null}, then {@code "null"} is added.
  2437      * Note that if an individual element is {@code null}, then {@code "null"} is added.