Here you can find the source of implode(String separator, String... data)
public static String implode(String separator, String... data)
//package com.java2s; //License from project: Apache License public class Main { public static String implode(String separator, String... data) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < data.length - 1; i++) { //data.length - 1 => to not add separator at the end if (!data[i].matches(" *")) {//empty string are ""; " "; " "; and so on sb.append(data[i]);/*from w w w . j a v a 2 s.c om*/ sb.append(separator); } } sb.append(data[data.length - 1].trim()); return sb.toString(); } }