Here you can find the source of listToString(List extends Object> list)
public static final String listToString(List<? extends Object> list)
//package com.java2s; //License from project: Apache License import java.util.List; public class Main { public static final String listToString(List<? extends Object> list) { if (null == list) return ""; if (list.isEmpty()) return "[]"; StringBuilder sb = new StringBuilder("["); for (int i = 0; i < list.size(); i++) { sb.append(list.get(i));/*from w w w. jav a 2 s .c om*/ if (i != (list.size() - 1)) { sb.append(','); } } sb.append(']'); return sb.toString(); } }