Java List Join joinList(List items)

Here you can find the source of joinList(List items)

Description

joins a list of elements eg [a, b, c] into a string of the form: "a", "b", "c" if the list is empty: returns "\"\"" (that is, a string containing two " characters, not an empty string)

License

Open Source License

Declaration

public static <E extends CharSequence> String joinList(List<E> items) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.List;

public class Main {
    /**// w w  w .j  av  a  2s  .c  om
     * joins a list of elements eg [a, b, c] into a string of the form:
     * "a", "b", "c"
     *
     * if the list is empty: returns "\"\"" (that is, a string containing two " characters, not an empty string)
     */
    public static <E extends CharSequence> String joinList(List<E> items) {
        return "\"" + String.join("\", \"", items) + "\"";
    }
}

Related

  1. joinLinesWithImplicitFinalLine(final List lines)
  2. joinList(final List list)
  3. joinList(final List list, final String sep)
  4. joinList(List list, String separator)
  5. joinList(List list, String separator)
  6. joinList(List list, String glue)
  7. joinList(List list, String separator)
  8. joinList(List parts, String sep)
  9. joinList(String separater, List list)