Here you can find the source of concatenate(Collection> coll)
public static String concatenate(Collection<?> coll)
//package com.java2s; /******************************************************************************* * Copyright (c) 2010, 2012 Tasktop Technologies * Copyright (c) 2010, 2011 SpringSource, a division of VMware * //from w w w . j av a 2s. c om * 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: * Tasktop Technologies - initial API and implementation ******************************************************************************/ import java.util.Collection; import java.util.Iterator; public class Main { public static String concatenate(Collection<?> coll) { StringBuilder sb = new StringBuilder(); Iterator<?> it = coll.iterator(); while (it.hasNext()) { sb.append(it.next()); if (it.hasNext()) { sb.append(' '); } } return sb.toString(); } }