Here you can find the source of join(T[] array, String separator)
public static <T> String join(T[] array, String separator)
//package com.java2s; /*//from w ww . j a v a2 s.co m * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved. * Use of this file is governed by the BSD 3-clause license that * can be found in the LICENSE.txt file in the project root. */ import java.util.Iterator; public class Main { public static <T> String join(Iterator<T> iter, String separator) { StringBuilder buf = new StringBuilder(); while (iter.hasNext()) { buf.append(iter.next()); if (iter.hasNext()) { buf.append(separator); } } return buf.toString(); } public static <T> String join(T[] array, String separator) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < array.length; i++) { builder.append(array[i]); if (i < array.length - 1) { builder.append(separator); } } return builder.toString(); } }