Java Collection to String asString(Collection collection)

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

Description

as String

License

Open Source License

Declaration

public static final String asString(Collection<? extends String> collection) 

Method Source Code


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

import java.util.Collection;

public class Main {
    public static final String asString(Collection<? extends String> collection) {
        if (isEmpty(collection)) {
            return "";
        }//from   w ww  .  j  a  va  2s .  c o  m
        final StringBuilder asList = new StringBuilder(64);
        for (String item : collection) {
            asList.append(", ").append(item);
        }
        return asList.substring(2);
    }

    public static final boolean isEmpty(Collection<?> collection) {
        return (collection == null || collection.size() == 0);
    }
}

Related

  1. asString(Collection c, String separator)
  2. asStringArr(Collection collection)
  3. asStringArray(Collection coll)
  4. asStringArray(Collection collection)
  5. buildString(Collection args, String seperator, int startingArg, int maxLength)