Here you can find the source of join(String delim, Object... objects)
delim
and return it as a string.
public static String join(String delim, Object... objects)
//package com.java2s; /*//from w w w. j a v a2 s . c o m * Carrot2 project. * * Copyright (C) 2002-2016, Dawid Weiss, Stanis?aw Osi?ski. * All rights reserved. * * Refer to the full license file "carrot2.LICENSE" * in the root folder of the repository checkout or at: * http://www.carrot2.org/carrot2.LICENSE */ import java.util.Iterator; public class Main { /** * Join a list of non-null objects with <code>delim</code> and return it * as a string. */ public static String join(String delim, Object... objects) { final StringBuilder b = new StringBuilder(); for (Object s : objects) { if (s != null) { if (b.length() > 0) b.append(delim); b.append(s.toString()); } } return b.toString(); } public static <T> String toString(Iterable<T> iterable, String separator) { final StringBuilder stringBuilder = new StringBuilder(); for (final Iterator<T> iterator = iterable.iterator(); iterator.hasNext();) { final T object = iterator.next(); stringBuilder.append(object); if (iterator.hasNext()) { stringBuilder.append(separator); } } return stringBuilder.toString(); } }