Java List from Array asList(T[] a)

Here you can find the source of asList(T[] a)

Description

Array to List.

License

Open Source License

Return

a list backed by the array.

Declaration

public static <T> List<T> asList(T[] a) 

Method Source Code

//package com.java2s;
// are made available under the terms of the Eclipse Public License v1.0

import java.util.Arrays;
import java.util.Collections;

import java.util.List;

public class Main {
    /** Array to List.//  w ww .  j a  v  a  2  s .  c  om
     * <p>
     * Works like {@link Arrays#asList(Object...)}, but handles null arrays.
     * @return a list backed by the array.
     */
    public static <T> List<T> asList(T[] a) {
        if (a == null)
            return Collections.emptyList();
        return Arrays.asList(a);
    }
}

Related

  1. asList(T... elements)
  2. asList(T... items)
  3. asList(T... values)
  4. asList(T... values)
  5. asList(T... values)
  6. asList(T[] array)
  7. asList(T[] array)
  8. asList(T[] array)
  9. asList(T[] array)