将arraylist连接成一个字符串,并用逗号将它们组合起来。
//package com.nowjava;/**from N o w J a v a . c o m**/ import java.util.ArrayList; public class Main { /** * Joins the arraylist into a single string, combining them with commas. * @param list * @return */ public static String join(ArrayList<String> list) { String item = ""; for (int i = 0; i < list.size(); i++) { if (i > 0) item += ","; item += list.get(i);