Java List from Array asList(Collection collection)

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

Description

as List

License

Open Source License

Declaration

@SuppressWarnings("unchecked")
    static public <E> List<E> asList(Collection collection) 

Method Source Code

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

import java.util.ArrayList;
import java.util.Collection;

import java.util.List;

public class Main {
    @SuppressWarnings("unchecked")
    static public <E> List<E> asList(Collection collection) {
        List<E> result = new ArrayList<E>();
        for (Object obj : collection) {
            result.add((E) obj);//from w  w w  .j a  va  2 s  .  co m
        }
        return result;
    }

    @SuppressWarnings("unchecked")
    static public <E> List<E> asList(Collection collection, E[] a) {
        List<E> result = new ArrayList<E>();
        for (Object obj : collection) {
            result.add((E) obj);
        }
        return result;
    }
}

Related

  1. arrayToStringList(Object array)
  2. asList()
  3. asList(boolean[] array)
  4. asList(byte[] array)
  5. asList(Class... classesArray)
  6. asList(Collection collection, Class type)
  7. asList(Collection values)
  8. asList(Collection c)
  9. asList(Collection coll)