Here you can find the source of collectionToString(Iterable
Parameter | Description |
---|---|
T | the collection type |
c | the collection |
public static <T> String collectionToString(Iterable<T> c)
//package com.java2s; //License from project: Creative Commons License import java.util.Iterator; public class Main { /**// ww w . java 2s. com * Create a string representation of an iterable collection * @param <T> the collection type * @param c the collection * @return */ public static <T> String collectionToString(Iterable<T> c) { StringBuilder b = new StringBuilder(); b.append("["); Iterator<T> it = c.iterator(); while (it.hasNext()) { b.append(it.next()); if (it.hasNext()) b.append(","); } b.append("]"); return b.toString(); } }