Modifier and Type | Method and Description |
---|---|
static <E> ArrayList<E> |
newArrayList()
Returns a new mutable, empty
ArrayList instance. |
static <E> ArrayList<E> |
newArrayList(Iterable<? extends E> elements)
Returns a new mutable
ArrayList instance containing the given elements. |
static <E> ArrayList<E> |
newArrayList(Iterator<? extends E> elements)
Returns a new mutable
ArrayList instance containing the given elements. |
static <E> ArrayList<E> |
newArrayListWithCapacity(int initialArraySize)
Creates an
ArrayList instance backed by an array of the exact size specified;
equivalent to ArrayList(int) . |
public static <E> ArrayList<E> newArrayList()
ArrayList
instance.public static <E> ArrayList<E> newArrayListWithCapacity(int initialArraySize)
ArrayList
instance backed by an array of the exact size specified;
equivalent to ArrayList(int)
.initialArraySize
- the exact size of the initial backing array for the returned array list
(ArrayList
documentation calls this value the "capacity")ArrayList
which is guaranteed not to resize itself unless its size
reaches initialArraySize + 1
IllegalArgumentException
- if initialArraySize
is negativepublic static <E> ArrayList<E> newArrayList(Iterable<? extends E> elements)
ArrayList
instance containing the given elements.elements
- the elements that the list should contain, in orderArrayList
containing those elementsCopyright © 2011–2023 Google. All rights reserved.