Java ArrayList Create newArrayList()

Here you can find the source of newArrayList()

Description

new Array List

License

Open Source License

Declaration

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

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

import java.util.Iterator;

public class Main {
    public static <T> ArrayList<T> newArrayList() {
        ArrayList<T> newArrayList = new ArrayList<T>();
        return newArrayList;
    }/*  ww  w .j a  va  2  s .c  o m*/

    public static <T> ArrayList<T> newArrayList(Iterator<T> iterator) {
        ArrayList<T> newArrayList = new ArrayList<T>();
        while (iterator.hasNext()) {
            newArrayList.add(iterator.next());
        }
        return newArrayList;
    }

    public static <T> ArrayList<T> newArrayList(Iterable<T> iterable) {
        ArrayList<T> newArrayList = new ArrayList<T>();
        for (T element : iterable) {
            newArrayList.add(element);
        }
        return newArrayList;
    }

    public static <T> ArrayList<T> newArrayList(T[] values) {
        ArrayList<T> newArrayList = new ArrayList<T>();
        if (values == null) {
            return newArrayList;
        }
        for (T element : values) {
            newArrayList.add(element);
        }
        return newArrayList;
    }

    @SafeVarargs
    public static <T> ArrayList<T> newArrayList(T element0, T element1,
            T... elements) {
        ArrayList<T> newArrayList = new ArrayList<T>();
        newArrayList.add(element0);
        newArrayList.add(element1);
        for (T element : elements) {
            newArrayList.add(element);
        }
        return newArrayList;
    }
}

Related

  1. getArrayListFromString(String wordSequence, String separator)
  2. newArrayList()
  3. newArrayList()
  4. newArrayList()
  5. newArrayList()
  6. newArrayList()
  7. newArrayList()
  8. newArrayList()
  9. newArrayList()