Here you can find the source of join(Object[] array, String delim)
public static String join(Object[] array, String delim)
//package com.java2s; /***/*from www . j a v a2s . com*/ ** ** This library is free software; you can redistribute it and/or ** modify it under the terms of the GNU Lesser General Public ** License as published by the Free Software Foundation; either ** version 2.1 of the License, or (at your option) any later version. ** ** This library is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ** Lesser General Public License for more details. ** ** You should have received a copy of the GNU Lesser General Public ** License along with this library; if not, write to the Free Software ** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ** **/ import java.util.*; public class Main { /** * join the given string array with the given delimiter */ public static String join(Iterator it, String delim) { StringBuilder joined = new StringBuilder(); if (it != null) { while (it.hasNext()) { joined.append(it.next()); if (it.hasNext()) { joined.append(delim); } } } return joined.toString(); } /** * join the given string array with the given delimiter */ public static String join(Object[] array, String delim) { return join(array, 0, array.length, delim); } /** * join the given string array with the given delimiter */ public static String join(Object[] array, int start, int end, String delim) { if (array != null) { if (start > array.length || end < start) { return null; } if (start < 0) { start = 0; } if (end > array.length) { end = array.length; } StringBuilder joined = new StringBuilder(); for (int i = start; i < end; i++) { joined.append(array[i]); if ((i + 1) < end) { joined.append(delim); } } return joined.toString(); } else { return null; } } /** * join the given string array with the given delimiter */ public static String join(Iterable iterable, String delim) { return iterable != null ? join(iterable.iterator(), delim) : null; } }