Here you can find the source of convertArrayToList(T[] arrayOfObjects)
Parameter | Description |
---|---|
T | type of the objects... |
arrayOfObjects | the array we want to convert into the List<T> |
public static <T> List<T> convertArrayToList(T[] arrayOfObjects)
//package com.java2s; /**//from ww w . jav a2 s .c om * <p> * This software is distributed under the <a href="http://hci.stanford.edu/research/copyright.txt"> * BSD License</a>. * </p> * * @author <a href="http://graphics.stanford.edu/~ronyeh">Ron B Yeh</a> (ronyeh(AT)cs.stanford.edu) */ import java.util.ArrayList; import java.util.Collections; import java.util.List; public class Main { /** * @param <T> * type of the objects... * @param arrayOfObjects * the array we want to convert into the List<T> * @return an arraylist of <T>s */ public static <T> List<T> convertArrayToList(T[] arrayOfObjects) { final ArrayList<T> list = new ArrayList<T>(); Collections.addAll(list, arrayOfObjects); return list; } }