public final class Lists extends Object
List instances. Also see this
class's counterparts Sets, Maps and Queues.
See the Guava User Guide article on
Lists.
| Modifier and Type | Method and Description |
|---|---|
static <E> ArrayList<E> |
newArrayList(Iterable<? extends E> elements)
Creates a mutable
ArrayList instance containing the given
elements; a very thin shortcut for creating an empty list then calling
Iterables#addAll. |
static <E> ArrayList<E> |
newArrayList(Iterator<? extends E> elements)
Creates a mutable
ArrayList instance containing the given
elements; a very thin shortcut for creating an empty list and then calling
Iterators.addAll(java.util.Collection<T>, java.util.Iterator<? extends T>). |
public static <E> ArrayList<E> newArrayList(Iterable<? extends E> elements)
ArrayList instance containing the given
elements; a very thin shortcut for creating an empty list then calling
Iterables#addAll.
Note: if mutability is not required and the elements are
non-null, use ImmutableList#copyOf(Iterable) instead. (Or, change
elements to be a FluentIterable and call
elements.toList().)
Note for Java 7 and later: if elements is a Collection, you don't need this method. Use the ArrayList
constructor directly, taking
advantage of the new "diamond" syntax.
public static <E> ArrayList<E> newArrayList(Iterator<? extends E> elements)
ArrayList instance containing the given
elements; a very thin shortcut for creating an empty list and then calling
Iterators.addAll(java.util.Collection<T>, java.util.Iterator<? extends T>).
Note: if mutability is not required and the elements are
non-null, use ImmutableList#copyOf(Iterator) instead.
Copyright © 2007-2024, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.