Here you can find the source of printListWithDelimiter(Collection
public static <T> String printListWithDelimiter(Collection<T> list, String delimiter)
//package com.java2s; //License from project: LGPL import java.util.*; public class Main { public static <T> String printListWithDelimiter(Collection<T> list, String delimiter) { boolean first = true; StringBuilder sb = new StringBuilder(); for (T el : list) { if (first) { first = false;//from w w w . j av a 2s. com } else { sb.append(delimiter); } sb.append(el); } return sb.toString(); } }