Here you can find the source of listToString(List
public static <T> String listToString(List<T> list, String prefix, String delimiter, String suffix)
//package com.java2s; //License from project: BSD License import java.util.List; public class Main { public static <T> String listToString(List<T> list, String prefix, String delimiter, String suffix) { String listStr = prefix;/* ww w . ja v a 2 s . c o m*/ boolean isFirst = true; for (T element : list) { listStr += (isFirst ? "" : delimiter) + element.toString(); isFirst = false; } listStr += suffix; return listStr; } }