Here you can find the source of join(T[] array, String join)
public static <T> String join(T[] array, String join)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static <T> String join(T[] array, String join) { return join(array, join, array.length); }//from w ww.j a va 2 s.c om public static <T> String join(T[] array, String join, int limit) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < array.length && i < limit; i++) { builder.append(array[i].toString()); int pos = i + 1; boolean last = pos < array.length && pos < limit; if (!last) { builder.append(join); } } return builder.toString(); } public static <T> String join(List<T> list, String join) { return join(list, join, list.size()); } public static <T> String join(List<T> list, String join, int limit) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < list.size() && i < limit; i++) { builder.append(list.get(i).toString()); int pos = i + 1; boolean last = pos < list.size() && pos < limit; if (!last) { builder.append(join); } } return builder.toString(); } }