Java ArrayList Create newArrayList()

Here you can find the source of newArrayList()

Description

Type-safe initializer.

License

LGPL

Declaration


public static <T> ArrayList<T> newArrayList() 

Method Source Code


//package com.java2s;
// Metawidget (licensed under LGPL)

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

public class Main {
    /**/*w ww.j a v  a  2 s.c o m*/
     * Type-safe initializer.
     */

    public static <T> ArrayList<T> newArrayList() {

        return new ArrayList<T>();
    }

    /**
     * Type-safe initializer.
     */

    public static <T> ArrayList<T> newArrayList(Collection<T> collection) {

        return new ArrayList<T>(collection);
    }

    /**
     * Type-safe initializer.
     */

    public static <T> ArrayList<T> newArrayList(int capacity) {

        return new ArrayList<T>(capacity);
    }

    /**
     * Type-safe initializer.
     */

    public static <T> ArrayList<T> newArrayList(T... array) {

        if (array == null) {
            return new ArrayList<T>();
        }

        return new ArrayList<T>(Arrays.asList(array));
    }
}

Related

  1. getArrayList(String[] args)
  2. getArrayListForArray(Object[] rowData)
  3. getArrayListFromInt(int number)
  4. getArrayListFromString(String wordSequence, String separator)
  5. newArrayList()
  6. newArrayList()
  7. newArrayList()
  8. newArrayList()
  9. newArrayList()