Here you can find the source of createList(Class
Parameter | Description |
---|---|
T | Generic type parameter |
elementClass | The class of T |
public static <T> List<T> createList(Class<T> elementClass)
//package com.java2s; import java.util.ArrayList; import java.util.List; public class Main { /**/* ww w. ja va 2 s . co m*/ * Uses java generics to create a new ArrayList that can contain elements of the specified * elementClass. Calling a method appears to be the easiest way to achieve this. * * @param <T> Generic type parameter * @param elementClass The class of T * @return A new ArrayList that can contain elements of class elementClass. */ public static <T> List<T> createList(Class<T> elementClass) { return new ArrayList<T>(); } }