Java Collection Concatenate concatenate(Collection coll)

Here you can find the source of concatenate(Collection coll)

Description

concatenate

License

Open Source License

Declaration

public static String concatenate(Collection<?> coll) 

Method Source Code

//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();
    }
}

Related

  1. concat(String separator, Collection args)
  2. concat(String[] first, Collection second)
  3. concatCollection(Collection collection)
  4. concatElements(final Collection c, final String separator)
  5. concatenate(Collection collections)
  6. concatenate(Collection list)
  7. concatenate(final Collection objects, final String separator)
  8. concatenatedLTL(Collection ltl)
  9. concatenateIds(final Collection ids)