Java List Create asList(E[] array)

Here you can find the source of asList(E[] array)

Description

as List

License

Open Source License

Declaration

public static <E> List<E> asList(E[] array) 

Method Source Code


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

import java.util.*;

public class Main {
    public static <E> List<E> asList(E[] array) {
        if (isEmpty(array)) {
            return new ArrayList<>();
        }/*from ww w.  java  2  s  . com*/

        return Arrays.asList(array);
    }

    private static <E> boolean isEmpty(Collection<E> collection) {

        return (collection == null || collection.isEmpty());
    }

    private static <E> boolean isEmpty(E[] array) {

        return (array == null || array.length == 0);
    }
}

Related

  1. asList(Collection items)
  2. asList(E... elements)
  3. asList(final int... values)
  4. asList(final Iterator data)
  5. asList(int[] a)
  6. asList(int[] array)