public class Lists
extends java.lang.Object
List instances easily, and other
utility methods for working with lists.
Note: This was copied from the com.google.android.collect.Lists class| Constructor and Description |
|---|
Lists() |
| Modifier and Type | Method and Description |
|---|---|
static <E> java.util.ArrayList<E> |
newArrayList()
Creates an empty
ArrayList instance. |
static <E> java.util.ArrayList<E> |
newArrayList(E... elements)
Creates a resizable
ArrayList instance containing the given
elements. |
public static <E> java.util.ArrayList<E> newArrayList()
ArrayList instance.
Note: if you only need an immutable empty List, use
Collections.emptyList() instead.
ArrayListpublic static <E> java.util.ArrayList<E> newArrayList(E... elements)
ArrayList instance containing the given
elements.
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 elements