Java List Create createArrayList()

Here you can find the source of createArrayList()

Description

Returns a typed array list

License

Apache License

Declaration

public static <T> List<T> createArrayList() 

Method Source Code


//package com.java2s;
/*//ww w  .j a  v a  2  s  .c o m
 * Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
 * Copyright [2016-2018] EMBL-European Bioinformatics Institute
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import static java.util.Arrays.asList;
import java.util.ArrayList;

import java.util.List;

public class Main {
    /**
     * Returns a typed array list
     */
    public static <T> List<T> createArrayList() {
        return new ArrayList<T>();
    }

    /**
     * Returns a typed array list with the given initial capacity
     */
    public static <T> List<T> createArrayList(int initialCapacity) {
        return new ArrayList<T>(initialCapacity);
    }

    /**
     * Creates a list and populates it with the contents of args
     * 
     * @param <T>
     *            Generic type of list
     * @param args
     *            Elements to go into the list
     * @return List of args typed accordingly
     */
    public static <T> List<T> createArrayList(T... args) {
        List<T> list = createArrayList();
        list.addAll(asList(args));
        return list;
    }
}

Related

  1. create2DHorizontalIndexList( final int n)
  2. createActMask(ArrayList stateActions, ArrayList beliefActions)
  3. createAndInitializeList(int size, int begin)
  4. createArgumentList(List args)
  5. createArrayFromUsers(List userList)
  6. createBarrier(List text)
  7. createBlankSet(String date, List titleList)
  8. createBVQueryParametersList()
  9. createCategoryName(List names)