Here you can find the source of join(String c, Collection d)
public static String join(String c, Collection d)
//package com.java2s; /*/*www .j a v a 2 s .c o m*/ * Copyright (C) 2007 by Instytut Podstaw Informatyki Polskiej * Akademii Nauk (IPI PAN; Institute of Computer Science, Polish * Academy of Sciences; cf. www.ipipan.waw.pl). All rights reserved. * * This file is part of Spejd. * * Spejd is free software: it may be distributed and/or modified under * the terms of the GNU General Public License version 3 as published * by the Free Software Foundation and appearing in the file doc/gpl.txt * included in the packaging of this file. * * A commercial license is available from IPI PAN (contact * Michal.Ciesiolka@ipipan.waw.pl or ipi@ipipan.waw.pl for more * information). Licensees holding a valid commercial license from IPI * PAN may use this file in accordance with that license. * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE. */ import java.util.Collection; import java.util.Iterator; public class Main { /** * Similar to join / implode in php. */ public static String join(String c, Collection d) { StringBuilder res = new StringBuilder(); boolean notFirst = false; for (Iterator i = d.iterator(); i.hasNext();) { if (notFirst) res.append(c); else notFirst = true; res.append(i.next()); } return res.toString(); } }