Here you can find the source of implode(String[] array, String glue)
public static String implode(String[] array, String glue)
//package com.java2s; import java.util.Iterator; import java.util.List; public class Main { public static String implode(String[] array, String glue) { String str = ""; for (int i = 0; i < array.length; i++) { if (i < array.length - 1) { str += array[i] + glue;//from ww w . ja v a 2 s .c om } else { str += array[i]; } } return str; } public static String implode(List list, String glue) { String str = ""; int i = 0; for (Iterator it = list.iterator(); it.hasNext();) { Object object = (Object) it.next(); if (i < list.size() - 1) { str += object.toString() + glue; } else { str += object.toString(); } i++; } return str; } }