Java Collection Merge merge(final Collection values)

Here you can find the source of merge(final Collection values)

Description

merge

License

Open Source License

Declaration

static String merge(final Collection<String> values) 

Method Source Code

//package com.java2s;
/********************************************************************************
 * Copyright (c) 2009 Regents of the University of Minnesota
 *
 * This Software was written at the Minnesota Supercomputing Institute
 * http://msi.umn.edu/*from   ww  w. ja  va 2 s . c  om*/
 *
 * All rights reserved. The following statement of license applies
 * only to this file, and and not to the other files distributed with it
 * or derived therefrom.  This file is 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:
 * Minnesota Supercomputing Institute - initial API and implementation
 *******************************************************************************/

import java.util.Collection;

public class Main {
    static String merge(final Collection<String> values) {
        final StringBuilder merged = new StringBuilder();
        boolean first = true;
        for (String value : values) {
            if (!first) {
                merged.append(",");
            } else {
                first = false;
            }
            merged.append(value);
        }
        return merged.toString();
    }
}

Related

  1. merge(Collection splits)
  2. merge(Collection strings, char separator)
  3. merge(Collection... collections)
  4. merge(Collection... collections)
  5. merge(Collection... elems)
  6. merge(J just, Collection justs)
  7. mergeArrayIntoCollection(T[] array, Collection collection)
  8. mergeCollection( final Collection col1, final Collection col2)
  9. mergeCollection(Collection a, Collection b)