Here you can find the source of listToString(List
public static String listToString(List<Integer> list)
//package com.java2s; import java.util.Iterator; import java.util.List; public class Main { public static String listToString(List<Integer> list) { String str = ""; if ((list != null) && (list.size() > 0)) { for (Iterator i$ = list.iterator(); i$.hasNext();) { int id = ((Integer) i$.next()).intValue(); str = str + id + ","; }/*from w w w.ja v a 2 s . c o m*/ if ((!("".equals(str))) && (str.length() > 0)) str = str.substring(0, str.length() - 1); } return str; } public static boolean equals(String s1, String s2) { if ((isEmpty(s1)) && (isEmpty(s2))) return true; if ((!(isEmpty(s1))) && (!(isEmpty(s2)))) return s1.equals(s2); return false; } public static boolean isEmpty(String s) { return ((s == null) || ("".equals(s))); } public static String isEmpty(String s, String result) { if ((s != null) && (!(s.equals("")))) return s; return result; } }