Java tutorial
//package com.java2s; /* * Copyright 2012 sohu.com All right reserved. This software is the * confidential and proprietary information of sohu.com ("Confidential * Information"). You shall not disclose such Confidential Information and shall * use it only in accordance with the terms of the license agreement you entered * into with sohu.com. */ import java.util.List; public class Main { public static <T> String listToString(List<T> list) { if (null == list || list.isEmpty()) { return ""; } StringBuilder sb = new StringBuilder(); for (T i : list) { sb.append(i.toString()); sb.append(","); } int index = sb.lastIndexOf(","); if (-1 != index) { sb.deleteCharAt(index); } return sb.toString(); } }