Java Utililty Methods ArrayList Create

List of utility methods to do ArrayList Create

Description

The list of methods to do ArrayList Create are organized into topic(s).

Method

ArrayListasArrayList(Collection list)
as Array List
if (ArrayList.class.isInstance(list)) {
    return (ArrayList<E>) list;
} else {
    return new ArrayList<E>(list);
ListasArrayList(Collection collection)
If input collection is ArrayList then return it.
if (collection instanceof ArrayList) {
    return (List<T>) collection;
return new ArrayList<T>(collection);
ArrayListcreateArrayList()
create Array List
return new ArrayList<E>();
ArrayListcreateArrayList()
create Array List
return new ArrayList<T>();
ListcreateArrayList(Collection arg)
create Array List
return new ArrayList<T>(arg);
ArrayListcreateArrayList(E... array)
create Array List
ArrayList<E> newCollection = new ArrayList<E>();
if (array != null) {
    Collections.addAll(newCollection, array);
return newCollection;
ArrayListcreateArrayList(final DataType first, final DataType second)
Creates a new ArrayList from the given pair of values.
final ArrayList<DataType> result = new ArrayList<DataType>(2);
result.add(first);
result.add(second);
return result;
ArrayListcreateArrayList(Iterable items, int size)
create Array List
ArrayList<T> al = new ArrayList<>(size);
for (T item : items) {
    al.add(item);
return al;
ArrayListcreateArrayList(Object[] a)
create Array List
ArrayList al = new ArrayList(a.length);
for (int i = 0; i < a.length; i++)
    al.add(a[i]);
return al;
ArrayListcreateArrayList(String[] a)
create Array List
ArrayList<String> b = new ArrayList<String>();
for (int i = 0; i < a.length; i++) {
    b.add(a[i]);
return b;