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

ArrayListnewArrayList(Iterable iterable)
new Array List
if (iterable == null) {
    throw new NullPointerException();
ArrayList<E> list = new ArrayList<E>();
for (Iterator<E> i = iterable.iterator(); i.hasNext();) {
    list.add(i.next());
return list;
...
ListnewArrayList(T anObj)
Creates a new array list with given object.
return newArrayList(10, anObj);
ListnewArrayList(T... elements)
Avoid dependency on Guava types
List<T> list = new ArrayList<>(1);
Collections.addAll(list, elements);
return list;
ListnewArrayList(T... items)
new Array List
List<T> list = new ArrayList<T>();
for (T t : items) {
    list.add(t);
return list;
ListnewArrayList(T... objectList)
new Array List
List<T> list = new ArrayList<T>(objectList.length);
for (T obj : objectList) {
    list.add(obj);
return list;
ListnewArrayList(T... objs)
Returns the value mapped by key, or if no mapping exists, puts to map and returns the value supplied by valueSupplier.
List<T> results = new ArrayList<T>();
results.addAll(Arrays.asList(objs));
return results;
ListnewArrayList(X... args)
new Array List
return Arrays.asList(args);
ListnewArrayListOnNull(List list)
new Array List On Null
if (list == null) {
    list = new ArrayList<T>();
return list;
ArrayListnewArrayListSized(Iterable fromSize)
Creates a new ArrayList which if possible is sized the same as the passed in iterable (ie only if it is actually a Collection).
if (fromSize instanceof Collection<?>)
    return new ArrayList<T>(((Collection<?>) fromSize).size());
else
    return new ArrayList<T>();
ArrayListnewArrayListWithCapacity(int initSize)
new Array List With Capacity
return new ArrayList<T>(initSize);