Java Collection to String collectionToStr(Collection collection)

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

Description

collection To Str

License

Open Source License

Declaration

public static <T> String collectionToStr(Collection<T> collection) 

Method Source Code

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

import java.util.*;

public class Main {
    public static <T> String collectionToStr(Collection<T> collection) {
        StringBuilder result = new StringBuilder("");
        if (collection == null) {
            return result.toString();
        }/*from  w w w . j av  a2 s . c o m*/
        T[] array = (T[]) collection.toArray();
        for (int i = 0; i < array.length; i++) {
            result.append(array[i]);
            if (i != array.length - 1) {
                result.append(",");
            }
        }
        return result.toString();
    }
}

Related

  1. collectionToDelimitedString(Collection coll, String delim)
  2. collectionToDelimitedString(Collection coll, String delim, String prefix, String suffix)
  3. collectionToDelimitedString(Collection values, String delimiter)
  4. collectionToStr(Collection collection)
  5. CollectionToStr(Collection coll)
  6. collectionToString( Collection collection)
  7. collectionToString(@SuppressWarnings("rawtypes") Collection coll)
  8. collectionToString(Collection c)
  9. collectionToString(Collection c, String delim)