Java List from Array asList(Iterable iterable)

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

Description

Returns a {List} of the contents for the given {Iterable}

License

Apache License

Parameter

Parameter Description
iterable The Iterable
T The type of objects contained in the {Iterable}

Return

A {List} of the iterable's objects

Declaration

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

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

public class Main {
    /**/*www.ja v  a2s  .  c  o  m*/
     * Returns a {List} of the contents for the given {Iterable}
     *
     * @param iterable The Iterable
     * @param <T>      The type of objects contained in the {Iterable}
     * @return A {List} of the iterable's objects
     */
    public static <T> List<T> asList(Iterable<T> iterable) {
        List<T> list = new ArrayList<T>();

        for (T item : iterable) {
            list.add(item);
        }

        return list;
    }
}

Related

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