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 intoCollection, Collection fromCollection)
Adds all the items in "fromCollection" into "intoCollection".
for (T t : fromCollection) {
    intoCollection.add(t);
voidaddAll(Collection left, Collection right)
Add all from right to left collection
if (left != null && right != null) {
    left.addAll(right);
CollectionaddAll(Collection t1, Iterable t2)
Utility for adding an iterable to a collection.
for (T t : t2) {
    t1.add(t);
return t1;
voidaddAll(Collection target, Collection source)
add All
if (target != null && source != null && source.size() > 0) {
    target.addAll(source);
voidaddAll(Collection target, Iterable source)
add All
for (T t : source) {
    target.add(t);
voidaddAll(Collection target, S[] source)
Adds all elements from source to target.
if (source != null) {
    for (int s = 0, n = source.length; s < n; s++) {
        target.add(source[s]);
voidaddAll(final Collection coll, final Object[] array)
Convenience method that adds all members of an array to a collection.
for (int i = 0; i < array.length; i++) {
    coll.add(array[i]);
booleanaddAll(final Collection newItems, final Collection existingItems)
Adds the given items to the given collection
if ((existingItems != null) && (newItems != null)) {
    return existingItems.addAll(newItems);
return false;
booleanaddAll(final Collection c, final E... array)
add All
boolean result = false;
for (final E element : array) {
    result |= c.add(element);
return result;
voidaddAll(final Collection thingsToBeAddedTo, final Collection thingsToAdd)
Adds thingsToAdd to thingsToBeAddedTo.
if (thingsToBeAddedTo == null) {
    throw new IllegalArgumentException("There's no thingsToBeAddedTo!");
if (!isEmpty(thingsToAdd)) {
    thingsToBeAddedTo.addAll(thingsToAdd);