Java Utililty Methods Collection Create

List of utility methods to do Collection Create

Description

The list of methods to do Collection Create are organized into topic(s).

Method

Setcreate(Collection coll)
Creates a set containing all the elements in the collection
return new HashSet<T>(coll);
StringcreateAuthorString(Collection users)
create Author String
Collection<String> alreadySeen = new ArrayList<String>();
String authorLabel = "";
Iterator c = users.iterator();
boolean firstAuthor = true;
while (c.hasNext()) {
    String nextAuthor = (String) c.next();
    if (nextAuthor == null)
        continue;
...
CollectioncreateCollection(final Iterable object)
create Collection
final Collection<T> collection = new ArrayList<T>();
for (final T item : object) {
    collection.add(item);
return collection;
CollectioncreateCollection(Collection col)
Create and answer a collection that is the same type, or the closest equivalent of col.
Collection answer;
try {
    answer = (Collection) col.getClass().newInstance();
} catch (Exception e) {
    if (col instanceof List) {
        answer = new ArrayList();
    } else if (col instanceof SortedSet) {
        answer = new TreeSet();
...
CollectioncreateCollection(Object[] objects)
create Collection
Collection result = createCollection();
for (int i = 0; i < objects.length; i++) {
    result.add(objects[i]);
return result;
CollectioncreateCollection(T... items)
create Collection
Collection<T> collection = new ArrayList<T>(items.length);
for (T item : items) {
    collection.add(item);
return collection;
CollectioncreateCollection(X o)
create Collection
return createList(o);
CollectioncreateCollectionFromString(String value)
create Collection From String
if (value == null) {
    return null;
final StringTokenizer t = new StringTokenizer(value, COLLECTION_SEPARATOR);
final List result = new ArrayList();
while (t.hasMoreTokens()) {
    result.add(t.nextToken());
return result;
StringcreateCSV(Collection list)
create CSV
return createCSV(list, null);
StringcreateCsvString(Collection in)
Create string with comma separated list of values from input collection.
if (in == null)
    return null;
if (in.isEmpty()) {
    return "";
boolean first = true;
StringBuilder sb = new StringBuilder();
for (String s : in) {
...