Adds all of the specified elements to the specified collection.
Elements to be added may be specified individually or as an array.
The behavior of this convenience method is identical to that of
c.addAll(Arrays.asList(elements))
, but this method is likely
to run significantly faster under most implementations.
When elements are specified individually, this method provides a convenient way to add a few elements to an existing collection:
Collections.addAll(flavors, "Peaches 'n Plutonium", "Rocky Racoon");
<T> | the class of the elements to add and of the collection | |
c | the collection into which elements are to be inserted | |
elements | the elements to insert into c |
true
if the collection changed as a result of the call
UnsupportedOperationException | if c does not support
the add operation | |
NullPointerException | if elements contains one or more
null values and c does not permit null elements, or
if c or elements are null | |
IllegalArgumentException | if some property of a value in
elements prevents it from being added to c |
Collection.addAll(Collection)
Diagram: Collections