Java ArrayList Create newArrayList(int initialCapacity)

Here you can find the source of newArrayList(int initialCapacity)

Description

Constructs an empty list with the specified initial capacity.

License

Open Source License

Parameter

Parameter Description
T a parameter
initialCapacity a parameter

Declaration

public static <T> List<T> newArrayList(int initialCapacity) 

Method Source Code


//package com.java2s;
import java.util.ArrayList;

import java.util.List;

public class Main {
    /**//ww w .  j av a  2s  .com
     * Constructs an empty list with the specified initial capacity.
     * 
     * @param <T>
     * @param initialCapacity
     * @return
     */
    public static <T> List<T> newArrayList(int initialCapacity) {
        return new ArrayList<T>(initialCapacity);
    }

    /**
     * Constructs an empty list with an initial capacity of ten.
     * 
     * @param <T>
     * @return
     */
    public static <T> List<T> newArrayList() {
        return newArrayList(10);
    }

    /**
     * @param enemyList
     * @return
     */
    public static <T> List<T> newArrayList(List<T> c) {
        return new ArrayList<T>(c);
    }
}

Related

  1. newArrayList(Collection collection)
  2. newArrayList(E... elements)
  3. newArrayList(E... elements)
  4. newArrayList(final Collection elements)
  5. newArrayList(final Iterator iter)
  6. newArrayList(int initialCapacity)
  7. newArrayList(int initialCapacity)
  8. newArrayList(int initialCapacity)
  9. newArrayList(int size)