Here you can find the source of asList(E[] array)
Given an array of a particular type, it will return it as a List of the same type.
Parameter | Description |
---|---|
array | a parameter |
public static <E> List<E> asList(E[] array)
//package com.java2s; import java.util.ArrayList; import java.util.List; public class Main { /**// w w w . ja v a2 s . co m * <p>Given an array of a particular type, it will return it * as a List of the same type.</p> * * @param <E> * @param array * @return <E> {@link List}<E> */ public static <E> List<E> asList(E[] array) { List<E> list = new ArrayList<E>(array.length); for (int i = 0; i < array.length; i++) { list.add(array[i]); } return list; } }