Here you can find the source of implode(String[] values, String separator, String beforeEach, String afterEach)
public static String implode(String[] values, String separator, String beforeEach, String afterEach)
//package com.java2s; //License from project: Apache License import java.util.List; public class Main { public static String implode(int[] values, String separator) { StringBuffer result = new StringBuffer(); for (int i = 0; i < values.length; i++) { if (i > 0) result.append(separator); result.append(values[i]);//from www. ja v a2 s . com } return result.toString(); } public static String implode(String[] values, String separator) { StringBuffer result = new StringBuffer(); for (int i = 0; i < values.length; i++) { if (i > 0) result.append(separator); result.append(values[i]); } return result.toString(); } public static String implode(String[] values, String separator, String beforeEach, String afterEach) { StringBuffer result = new StringBuffer(); for (int i = 0; i < values.length; i++) { if (i > 0) result.append(separator); result.append(beforeEach); result.append(values[i]); result.append(afterEach); } return result.toString(); } public static String implode(List<String> a, String separator) { return implode(a.toArray(new String[a.size()]), separator); } }