Here you can find the source of join(Collection> objs, String delim)
public static String join(Collection<?> objs, String delim)
//package com.java2s; // are made available under the terms of the Eclipse Public License v1.0 import java.util.Collection; public class Main { public static String join(Object[] objs, String delim) { if (objs == null) { return ""; }/*from w w w . j a v a 2s.c om*/ StringBuilder ret = new StringBuilder(); int len = objs.length; for (int i = 0; i < len; i++) { if (i > 0) { ret.append(delim); } if (objs[i] instanceof String) { ret.append('"').append(objs[i]).append('"'); } else { ret.append(objs[i]); } } return ret.toString(); } public static String join(Collection<?> objs, String delim) { if (objs == null) { return ""; } StringBuilder ret = new StringBuilder(); boolean needDelim = false; for (Object obj : objs) { if (needDelim) { ret.append(delim); } if (obj instanceof String) { ret.append('"').append(obj).append('"'); } else { ret.append(obj); } needDelim = true; } return ret.toString(); } }