Here you can find the source of listToString(List> items)
Parameter | Description |
---|---|
items | a parameter |
public static String listToString(List<?> items)
//package com.java2s; import java.util.List; public class Main { /**// w w w.j a va 2s.c om * Return a string with the listed items separated by ", " * @param items * @return a string */ public static String listToString(List<?> items) { return listToString(items, ", "); } /** * Return a string with the listed items separated by the given separator * @param items * @param separator * @return a string */ public static String listToString(List<?> items, String separator) { boolean doneOne = false; final StringBuffer sb = new StringBuffer(); for (Object o : items) { if (doneOne) sb.append(separator); doneOne = true; sb.append(o.toString()); } return sb.toString(); } }