Here you can find the source of collectionToCommaDelimitedString(Collection> items)
public static String collectionToCommaDelimitedString(Collection<?> items)
//package com.java2s; /******************************************************************************* * Copyright (c) 2015 Pivotal, Inc.//www . jav a2 s . c o m * 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: * Pivotal, Inc. - initial API and implementation *******************************************************************************/ import java.util.Collection; public class Main { public static String collectionToCommaDelimitedString(Collection<?> items) { StringBuilder buf = new StringBuilder(); boolean first = true; for (Object item : items) { if (!first) { buf.append(","); } buf.append(item); first = false; } return buf.toString(); } }