Java tutorial
//package com.java2s; import java.util.ArrayList; public class Main { public static String implode(String[] ary, String delim) { String out = ""; for (int i = 0; i < ary.length; i++) { //if (ary[i]!=null) { out += ary[i]; if (i < (ary.length - 1)) { out += delim; } //} } return out; } @SuppressWarnings("rawtypes") public static String implode(ArrayList ary, String delim) { String out = ""; for (int i = 0; i < ary.size(); i++) { //if (ary.get(i)!=null) { out += (String) ary.get(i); if (i != ary.size() - 1) { out += delim; } //} } return out; } }