Java List from Array asList()

Here you can find the source of asList()

Description

as List

License

Open Source License

Declaration

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

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 <T> List<T> asList() {
        return new ArrayList<T>();
    }/*from   w w  w . java2s  .co  m*/

    public static <T> List<T> asList(T e0) {
        List<T> list = new ArrayList<T>();
        list.add(e0);
        return list;
    }

    public static <T> List<T> asList(T e0, T e1) {
        List<T> list = new ArrayList<T>();
        list.add(e0);
        list.add(e1);
        return list;
    }

    public static <T> List<T> asList(T e0, T e1, T e2) {
        List<T> list = new ArrayList<T>();
        list.add(e0);
        list.add(e1);
        list.add(e2);
        return list;
    }

    public static <T> List<T> asList(T e0, T e1, T e2, T e3) {
        List<T> list = new ArrayList<T>();
        list.add(e0);
        list.add(e1);
        list.add(e2);
        list.add(e3);
        return list;
    }

    public static <T> List<T> asList(T e0, T e1, T e2, T e3, T e4) {
        List<T> list = new ArrayList<T>();
        list.add(e0);
        list.add(e1);
        list.add(e2);
        list.add(e3);
        list.add(e4);
        return list;
    }
}

Related

  1. arrayToList(T[] obj, List newList)
  2. arrayToList(T[] source)
  3. arrayToListWithUpperCase(String[] arrValues)
  4. arrayToString(List arr)
  5. arrayToStringList(Object array)
  6. asList(boolean[] array)
  7. asList(byte[] array)
  8. asList(Class... classesArray)
  9. asList(Collection collection)