Java Utililty Methods Collection Add

List of utility methods to do Collection Add

Description

The list of methods to do Collection Add are organized into topic(s).

Method

voidaddAll(Collection collection, T... array)
add All
for (T t : array) {
    collection.add(t);
voidaddAll(Collection collection, T... elementsToAdd)
Adds all elements to the Collection .
if (collection != null && elementsToAdd != null) {
    Collections.addAll(collection, elementsToAdd);
voidaddAll(Collection collection, T... elementsToAdd)
Adds all elements to the Collection .
if (collection != null && elementsToAdd != null) {
    for (T toAdd : elementsToAdd) {
        collection.add(toAdd);
CollectionaddAll(Collection collection, T... newElements)
Add the contents of an array to a collection and return the collection.
Collections.addAll(collection, newElements);
return collection;
CollectionaddAll(Collection collection, T[] array)
Adds all elements from array to collection.
for (int i = 0; i < array.length; i++) {
    collection.add(array[i]);
return collection;
voidaddAll(Collection collection, T[] array)
add All
for (int i = 0; i < array.length; ++i)
    collection.add(array[i]);
voidaddAll(Collection collection, T[] items)
Adds specified items to the specified collection.
for (T newElem : items) {
    collection.add(newElem);
voidaddAll(Collection dest, Collection src, Class type)
add All
if (dest == null || src == null || type == null) {
    throw new IllegalArgumentException("Arguments must not be null.");
for (Object element : src) {
    if (element != null && type.isAssignableFrom(element.getClass())) {
        dest.add((T) element);
voidaddAll(Collection dest, Collection orig)
Null safe method for adding all the elements in "orig" to "dest"
if (!isEmpty(orig)) {
    dest.addAll(orig);
booleanaddAll(Collection dest, T... elements)
Adds element from an array into a collection.
boolean result = false;
for (final T e : elements) {
    result = dest.add(e) | result;
return result;