Java List from Array asList(Iterable iterable)

Here you can find the source of asList(Iterable iterable)

Description

as List

License

Open Source License

Declaration

public static <T> List<T> asList(Iterable<T> iterable) 

Method Source Code


//package com.java2s;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static <T> List<T> asList(Iterable<T> iterable) {
        if (List.class.isAssignableFrom(iterable.getClass())) {
            return (List<T>) iterable;
        } else {//from ww  w  .j  a va2  s .com
            List<T> list = new ArrayList<T>();
            for (T item : iterable) {
                list.add(item);
            }
            return list;
        }
    }
}

Related

  1. asList(int[] arr)
  2. asList(int[] ints)
  3. asList(int[] list)
  4. asList(int[] values)
  5. asList(Iterable iterable)
  6. asList(Iterable iterable)
  7. asList(Iterable iterable)
  8. asList(Iterator iterator)
  9. asList(List list)