Java List Create createList(Class elementClass)

Here you can find the source of createList(Class elementClass)

Description

Uses java generics to create a new ArrayList that can contain elements of the specified elementClass.

License

Open Source License

Parameter

Parameter Description
T Generic type parameter
elementClass The class of T

Return

A new ArrayList that can contain elements of class elementClass.

Declaration

public static <T> List<T> createList(Class<T> elementClass) 

Method Source Code

//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>();
    }
}

Related

  1. createIntListToN(int n)
  2. createKeyValPair(List lst)
  3. createLimitSql(StringBuilder sql, Integer startNum, Integer rowNum, List params)
  4. createList( Iterator iterator )
  5. createList()
  6. createList(Class itemClazz, T... items)
  7. createList(Collection collection)
  8. createList(Collection collection)
  9. createList(Collection collection)

  10. HOME | Copyright © www.java2s.com 2016