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.Iterator; public class Main { public static String join(String seperator, String[] strings) { int length = strings.length; if (length == 0) return ""; StringBuffer buf = new StringBuffer(length * strings[0].length()).append(strings[0]); for (int i = 1; i < length; i++) { buf.append(seperator).append(strings[i]); }/* ww w .j a v a 2s.co m*/ return buf.toString(); } public static String join(String seperator, Iterator objects) { StringBuffer buf = new StringBuffer(); 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 ""; StringBuffer buf = new StringBuffer(len * 12); for (int i = 0; i < len - 1; i++) { buf.append(array[i]).append(", "); } return buf.append(array[len - 1]).toString(); } }