Here you can find the source of stringJoin(List list, String separator)
Parameter | Description |
---|---|
list | to join |
separator | separator to use |
public static String stringJoin(List list, String separator)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { /**// www . ja va 2s .com * Join a list of objects to a string with a given separator by calling Object.toString() on the elements. * * @param list to join * @param separator separator to use * @return the joined string. */ public static String stringJoin(List list, String separator) { StringBuilder ret = new StringBuilder(); boolean first = true; for (Object o : list) { if (!first) { ret.append(separator); } ret.append(o); first = false; } return ret.toString(); } }