Java Collection Convert toCommaString(Collection c)

Here you can find the source of toCommaString(Collection c)

Description

to Comma String

License

Apache License

Declaration

public static final String toCommaString(Collection<String> c) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Collection;

public class Main {

    public static final String toCommaString(Collection<String> c) {
        String commaStr = "";
        for (String str : c) {
            commaStr = commaStr + str + ",";
        }/*from   w w  w  .  j  a  v  a 2  s. c  om*/
        commaStr = commaStr.substring(0, commaStr.length() - 1);
        return commaStr;
    }

    public static final String toCommaString(String[] c) {
        String commaStr = "";
        for (int i = 0; i < c.length; i++) {
            commaStr = commaStr + c[i] + ",";
        }
        commaStr = commaStr.substring(0, commaStr.length() - 1);
        return commaStr;
    }
}

Related

  1. toCommaDelimitedStringInQuotes(Collection c)
  2. toCommaSep(Collection strings)
  3. toCommaSeparatedString(final Collection items)
  4. toCommaSeparatedValues(Collection list)
  5. toCommaSepared(Collection aListOfString)
  6. toCsvString(Collection collection)
  7. toCSVString(Collection theCollection, String theSeparator)
  8. toDelimitedList(Collection values, String delimiter)
  9. toDelimitedString(Collection c, String delimiter)