Here you can find the source of collectionToString(Collection extends Object> c)
static public String collectionToString(Collection<? extends Object> c)
//package com.java2s; /******************************************************************************* * Copyright (c) 2007, 2011 Intel Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from w w w . j av a2s . c o m * Intel Corporation - Initial API and implementation *******************************************************************************/ import java.util.Collection; public class Main { static public String collectionToString(Collection<? extends Object> c) { return arrayToString(c.toArray()); } static public String arrayToString(Object[] arr) { StringBuffer buf = new StringBuffer(); buf.append('['); for (int i = 0; i < arr.length; i++) { if (i != 0) buf.append(", "); buf.append(arr[i].toString()); } buf.append(']'); return buf.toString(); } }