Here you can find the source of joinWith(Iterable
public static String joinWith(Iterable<String> elements, String join)
//package com.java2s; //License from project: Open Source License import java.util.Iterator; public class Main { public static String joinWith(Iterable<String> elements, String join) { StringBuilder result = new StringBuilder(); Iterator<String> it = elements.iterator(); if (it.hasNext()) { result.append(it.next());//from w w w . ja v a 2 s . c o m } while (it.hasNext()) { result.append(join).append(it.next()); } return result.toString(); } }