Returns a List of the objects in the specified array. - Android java.lang

Android examples for java.lang:Array Element

Description

Returns a List of the objects in the specified array.

Demo Code


//package com.java2s;

import java.util.ArrayList;

import java.util.List;

public class Main {
    /**/*www.  j av  a2s .com*/
     * Returns a {@code List} of the objects in the specified array.
     * 
     * @param array the array.
     * @return a {@code List} of the elements of the specified array.
     */
    public static <T> List<T> asList(T[] array) {
        List<T> list = new ArrayList<T>();
        for (T object : array) {
            list.add(object);
        }
        return list;
    }
}

Related Tutorials