Here you can find the source of join(String[] array)
public static String join(String[] array)
//package com.java2s; //License from project: Apache License import java.util.Collection; import java.util.Iterator; import java.util.List; public class Main { public static String join(String[] array) { if (array.length == 0) { return ""; } else {/*from w w w . j av a 2 s. c o m*/ StringBuilder sb = new StringBuilder(); String[] arr$ = array; int len$ = array.length; for (int i$ = 0; i$ < len$; ++i$) { String s = arr$[i$]; sb.append(s); } return sb.toString(); } } public static String join(String[] array, char split) { if (array.length == 0) { return ""; } else { StringBuilder sb = new StringBuilder(); for (int i = 0; i < array.length; ++i) { if (i > 0) { sb.append(split); } sb.append(array[i]); } return sb.toString(); } } public static String join(String[] array, String split) { if (array.length == 0) { return ""; } else { StringBuilder sb = new StringBuilder(); for (int i = 0; i < array.length; ++i) { if (i > 0) { sb.append(split); } sb.append(array[i]); } return sb.toString(); } } public static String join(List<String> list, String separator, String quot, String defaultValue) { StringBuffer sb = new StringBuffer(); if (list == null || list.size() == 0) { return defaultValue; } else { for (String value : list) { if (sb.length() > 0 && separator != null) { sb.append(separator); } if (quot != null) { sb.append(quot); } sb.append(value); if (quot != null) { sb.append(quot); } } return sb.toString(); } } public static String join(Collection<String> coll, String split) { if (coll.isEmpty()) { return ""; } else { StringBuilder sb = new StringBuilder(); boolean isFirst = true; String s; for (Iterator i$ = coll.iterator(); i$.hasNext(); sb.append(s)) { s = (String) i$.next(); if (isFirst) { isFirst = false; } else { sb.append(split); } } return sb.toString(); } } public static String toString(String[] strArray, String separator) { String strResult = ""; if (strArray == null || separator == null) { strResult = null; } else { StringBuffer strBuffer = new StringBuffer(); for (int i = 0; i < strArray.length; i++) { if (strArray[i] == null || strArray[i].length() == 0) continue; strBuffer.append(separator); strBuffer.append(strArray[i]); } if (strBuffer.length() > 0) { strBuffer.delete(0, separator.length()); } strResult = strBuffer.toString(); } return strResult; } public static boolean isEmpty(String str) { return str == null || str.length() == 0; } }