Here you can find the source of listToString(List
public static String listToString(List<String> list)
//package com.java2s; /*//w w w . j ava 2 s . c o m * codjo.net * * Common Apache License 2.0 */ import java.util.List; public class Main { public static String listToString(List<String> list) { StringBuilder result = new StringBuilder(); if (list == null) { return ""; } for (String aList : list) { result.append(aList).append(", "); } if (!list.isEmpty()) { return result.substring(0, result.length() - 2); } else { return result.toString(); } } }