Here you can find the source of prettyPrint(Collection> c)
", "
, for display purposes.
Parameter | Description |
---|---|
c | The collection, which may be <code>null</code>. |
public static final String prettyPrint(Collection<?> c)
//package com.java2s; /*/*from ww w . ja va2 s. c om*/ * 03/16/2014 * * ZScriptUIUtils - Utility methods for the UI. * This library is distributed under a modified BSD license. See the included * ZScriptLanguageSupport.License.txt file for details. */ import java.util.Collection; public class Main { /** * Iterates over a collection of objects and joins them together with * <code>", "</code>, for display purposes. * * @param c The collection, which may be <code>null</code>. * @return A string representation of the collection's contents. */ public static final String prettyPrint(Collection<?> c) { if (c == null || c.isEmpty()) { return ""; } StringBuilder sb = new StringBuilder(); int size = c.size(); int i = 0; for (Object obj : c) { sb.append(obj); i++; if (i < size) { sb.append(", "); } } return sb.toString(); } }