Java tutorial
//package com.java2s; import java.util.Collection; public class Main { public static String mergeAllElements(Collection<String> collection) { StringBuffer stringBuffer = new StringBuffer(); Object[] str = collection.toArray(); for (int i = 0; i < str.length; i++) { if (i == str.length - 1) { stringBuffer.append(str[i].toString()); } else { stringBuffer.append(str[i].toString()).append(","); } } return stringBuffer.toString(); } }