Here you can find the source of join(String seperator, Iterator objects)
public static String join(String seperator, Iterator objects)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static String join(String seperator, String[] strings) { int length = strings.length; if (length == 0) return ""; StringBuilder buf = new StringBuilder(length * strings[0].length()).append(strings[0]); for (int i = 1; i < length; i++) { buf.append(seperator).append(strings[i]); }/*from w ww . jav a2s . c o m*/ return buf.toString(); } public static String join(String seperator, Iterator objects) { StringBuilder buf = new StringBuilder(); if (objects.hasNext()) buf.append(objects.next()); while (objects.hasNext()) { buf.append(seperator).append(objects.next()); } return buf.toString(); } public static String toString(Object[] array) { int len = array.length; if (len == 0) return ""; StringBuilder buf = new StringBuilder(len * 12); for (int i = 0; i < len - 1; i++) { buf.append(array[i]).append(", "); } return buf.append(array[len - 1]).toString(); } }