Java List from Array asList(T... array)

Here you can find the source of asList(T... array)

Description

as List

License

Open Source License

Declaration

@SafeVarargs
    static <T> List<T> asList(T... array) 

Method Source Code


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

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

public class Main {
    @SafeVarargs
    static <T> List<T> asList(T... array) {
        List<T> l = new ArrayList<T>();
        for (T t : array)
            l.add(t);// w  ww  . j  a v a 2s.  co  m
        return l;
    }

    static <T> List<T> asList(Iterator<T> iter) {
        List<T> l = new ArrayList<T>();
        while (iter.hasNext())
            l.add(iter.next());
        return l;
    }
}

Related

  1. asList(T... a)
  2. asList(T... a)
  3. asList(T... a)
  4. asList(T... args)
  5. asList(T... args)
  6. asList(T... array)
  7. asList(T... array)
  8. asList(T... data)
  9. asList(T... elements)