Here you can find the source of merge(List
public static String merge(List<String> list)
//package com.java2s; /* (c) 2014 Open Source Geospatial Foundation - all rights reserved * (c) 2001 - 2013 OpenPlans//from w ww.j a va2 s . co m * This code is licensed under the GPL 2.0 license, available at the root * application directory. */ import java.util.Iterator; import java.util.List; public class Main { public static String merge(List<String> list) { return merge(list, ","); } public static String merge(List<String> list, String separator) { StringBuilder sb = new StringBuilder(); for (Iterator<String> it = list.iterator(); it.hasNext();) { String string = it.next(); sb.append(string); if (it.hasNext()) { sb.append(separator); } } return sb.toString(); } }