Here you can find the source of join(List
Parameter | Description |
---|---|
list | List of Strings to join |
delimiter | String to delimit each item in list |
public static String join(List<String> list, String delimiter)
//package com.java2s; import java.util.List; public class Main { /**/*from w w w. j a v a 2 s .c o m*/ * This method joins together a list of Strings and separates them by a delimiter * * @param list * List of Strings to join * @param delimiter * String to delimit each item in list */ public static String join(List<String> list, String delimiter) { StringBuffer buf = new StringBuffer(""); if (list != null && list.size() > 0) for (int i = 0; i < list.size(); i++) if (i == 0) buf.append(list.get(i)); else buf.append(delimiter).append(list.get(i)); return buf.toString(); } }