Here you can find the source of join(final String[] arrays, final String seperator)
public static String join(final String[] arrays, final String seperator)
//package com.java2s; //License from project: Apache License import java.util.Collection; import java.util.Iterator; public class Main { public static String join(final String[] arrays, final String seperator) { final int len = arrays.length; if (arrays == null || len == 0) { return ""; }//from w w w .j av a 2s.c o m StringBuilder sb = new StringBuilder(); for (int i = 0; i < len; i++) { sb.append(arrays[i]); if (seperator != null && (i < len - 1)) { sb.append(seperator); } } return sb.toString(); } public static String join(final Collection<?> col, final String seperator) { final int size = col.size(); if (col == null || size == 0) { return ""; } StringBuilder sb = new StringBuilder(); for (Iterator<?> itr = col.iterator(); itr.hasNext();) { final Object item = itr.next(); sb.append(item.toString()); if (seperator != null && itr.hasNext()) { sb.append(seperator); } } return sb.toString(); } }