Java Collection Element Get getCommaSeparatedString(Collection collection)

Here you can find the source of getCommaSeparatedString(Collection collection)

Description

get Comma Separated String

License

Open Source License

Declaration

public static String getCommaSeparatedString(Collection<? extends Object> collection) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.Collection;
import java.util.Iterator;

public class Main {
    public static String getCommaSeparatedString(Collection<? extends Object> collection) {
        StringBuffer buffer = new StringBuffer();

        Iterator<? extends Object> iterator = collection.iterator();
        while (iterator.hasNext()) {
            Object obj = iterator.next();
            buffer.append(obj.toString());

            if (iterator.hasNext()) {
                buffer.append(", ");
            }//from w ww .  j av  a 2s .c  o  m
        }
        return buffer.toString();
    }
}

Related

  1. getCollectionClosingSymbol(Collection col)
  2. getCollectionPreview(final Collection collection, int previewSize)
  3. getCollectionSize(Collection collection)
  4. getCollectionSize(Collection collection)
  5. getCommaDelimitedString(Collection elements)
  6. getCommaSeparatedString(Collection values)
  7. getCommaSeparatedStringFromCollection(Collection collections)
  8. getCommon(Collection c1, Collection c2)
  9. getCommonElements( Collection from, Collection to)