Java Utililty Methods Collection to List

List of utility methods to do Collection to List

Description

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

Method

ListnewList(final Collection objects)
new List
return array(objects);
StringtoList(Collection addresses, char separator)
Format all strings in the collection by using the specified separator.
StringBuffer buf = new StringBuffer();
for (Iterator itr = addresses.iterator(); itr.hasNext();) {
    String address = (String) itr.next();
    if (buf.length() > 0)
        buf.append(separator);
    buf.append(address);
return buf.toString();
...
ListtoList(Collection collection)
Converts the given collection to a java.util.List.
if (collection instanceof List)
    return (List) collection;
List list = new ArrayList();
Iterator iterator = collection.iterator();
while (iterator.hasNext()) {
    list.add(iterator.next());
return list;
...
ListtoList(Collection collection)
Creates list from array/set of elements
int size = (collection == null) ? 0 : collection.size();
List<Object> result = new ArrayList<Object>(size);
if (collection != null)
    result.addAll(collection);
return result;
ListtoList(Collection c)
to List
if (c instanceof List)
    return (List<E>) c;
ArrayList<E> o = new ArrayList<E>(c.size());
for (E e : c)
    o.add(e);
return o;
ListtoList(Collection collection)
to List
if (collection == null)
    return null;
if (collection instanceof List) {
    return (List<E>) collection;
} else {
    return new ArrayList<E>(collection);
ListtoList(Collection lines)
to List
List<String> list = new ArrayList<String>(lines.size());
for (String line : lines) {
    list.add(line);
return list;
ListtoList(Collection c)
to List
return Collections.list(Collections.enumeration(c));
ListtoList(Collection c)
to List
return asList(c);
ListtoList(Collection collection)
Converts a collection to a list, either by casting or by explicit conversion.
return collection instanceof List ? (List<T>) collection : new ArrayList<T>(collection);