Java List Join join(List list, String sep)

Here you can find the source of join(List list, String sep)

Description

Assemble a list of items into a single string.

License

Apache License

Parameter

Parameter Description
list objects to assemble into string. toString() is called on each.
sep string to insert between each pair of items

Return

string

Declaration

public static String join(List<?> list, String sep) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.List;

public class Main {
    /**//from   w  ww .  j  a v  a  2s.c o m
     * Assemble a list of items into a single string.
     *
     * @param list objects to assemble into string.  toString() is called on each.
     * @param sep string to insert between each pair of items
     *
     * @return string
     */
    public static String join(List<?> list, String sep) {
        StringBuffer buf = new StringBuffer();
        for (int i = 0; i < list.size(); i++) {
            if (i > 0)
                buf.append(sep);
            buf.append(list.get(i).toString());
        }
        return buf.toString();
    }
}

Related

  1. join(List arr, String seperator)
  2. join(List items, char separator)
  3. join(List items, String delimiter)
  4. join(List list)
  5. join(List list, String delim)
  6. join(List objects, String delimiter)
  7. join(List parts)
  8. join(List resultList, String sep)
  9. join(List strings, String delimiter)