Java tutorial
//package com.java2s; /* * Copyright (c) 2006 Rick Mugridge, www.RimuResearch.com * Released under the terms of the GNU General Public License version 2 or later. * Written: 5/09/2006 */ import java.util.List; public class Main { public static <T> String mkString(String separator, List<T> ss) { return mkString(separator, ss.toArray()); } public static <T> String mkString(String separator, T... ss) { if (ss.length == 0) return ""; StringBuilder sb = new StringBuilder(); sb.append(ss[0]); for (int i = 1; i < ss.length; i++) sb.append(separator).append(ss[i]); return sb.toString(); } }