| Modifier and Type | Method and Description |
|---|---|
static <E> ArrayList<E> |
newArrayList()
Creates an empty
ArrayList instance. |
static <E> ArrayList<E> |
newArrayList(E... elements)
Creates an
ArrayList instance containing the given elements. |
static <E> ArrayList<E> |
newArrayList(E first,
E[] rest)
Returns an unmodifiable list containing the specified first element and
the additional elements.
|
static <E> ArrayList<E> |
newArrayList(Iterable<? extends E> elements)
Creates an
ArrayList instance containing the given elements. |
static <E> ArrayList<E> |
newArrayList(Iterator<? extends E> elements)
Creates an
ArrayList instance containing the given elements. |
public static <E> ArrayList<E> newArrayList()
ArrayList instance.
Note: if you need an immutable empty list, use Collections.emptyList() instead.
ArrayListpublic static <E> ArrayList<E> newArrayList(E... elements)
ArrayList instance containing the given elements.
Note: if you need an immutable List, use ImmutableList
instead.
Note: due to a bug in javac 1.5.0_06, we cannot support the following:
List<Base> list = Lists.newArrayList(sub1, sub2);
where sub1 and sub2 are references to subtypes of Base, not of Base itself. To get around this, you must use:
List<Base> list = Lists.<Base>newArrayList(sub1, sub2);
elements - the elements that the list should contain, in orderArrayList containing those elementspublic 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 elementspublic static <E> ArrayList<E> newArrayList(Iterator<? extends E> elements)
ArrayList instance containing the given elements.elements - the elements that the list should contain, in orderArrayList containing those elementsCopyright © 2006-2012 Google, Inc.. All Rights Reserved.