Here you can find the source of toString(final Collection
Parameter | Description |
---|---|
list | the list of strings |
delimiter | the delimiter |
public static String toString(final Collection<String> list, final String delimiter)
//package com.java2s; //License from project: Open Source License import java.util.Collection; public class Main { public static final String DELIMITER = ", "; /**//from w ww .j a v a 2s . c o m * Returns the list of strings as a single string * @param list the list of strings * @param delimiter the delimiter * @return the list as string */ public static String toString(final Collection<String> list, final String delimiter) { final StringBuilder sb = new StringBuilder(); for (final String string : list) { sb.append(string).append(delimiter); } sb.setLength(sb.length() - delimiter.length()); return sb.toString(); } /** * Returns the list of strings as a single string * @param list the list of strings * @return the list as string */ public static String toString(final Collection<String> list) { return toString(list, DELIMITER); } }