Java Iterable to List iterable2List(Iterable iterable)

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

Description

iterable List

License

Open Source License

Declaration

public static <E> List<E> iterable2List(Iterable<E> iterable) 

Method Source Code

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

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static <E> List<E> iterable2List(Iterable<E> iterable) {

        if (iterable instanceof List) {
            return (List<E>) iterable;
        }//from   ww w.  ja va 2s  .c om
        ArrayList<E> list = new ArrayList<E>();
        if (iterable != null) {
            for (E e : iterable) {
                list.add(e);
            }
        }
        return list;
    }
}

Related

  1. iterableAsList(Iterable iterable)
  2. iterableToCollection(Iterable c, Collection list)
  3. iterableToCollection(Iterable c, Collection list)
  4. iterableToList(Iterable iterable)