Java Utililty Methods Collection Merge

List of utility methods to do Collection Merge

Description

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

Method

voidmergeArrayIntoCollection(T[] array, Collection collection)
Merge the given array into the given Collection.
if (collection == null) {
    throw new IllegalArgumentException("Collection must not be null");
for (int i = 0; i < array.length; i++) {
    collection.add(array[i]);
CollectionmergeCollection(final Collection col1, final Collection col2)
Merge collections where all objects are of the same type.
if (col1 == null) {
    if (col2 == null) {
        return null;
    return col2;
if (col2 == null) {
    return col1;
...
CollectionmergeCollection(Collection a, Collection b)
merge Collection
if (a == null && b == null)
    return null;
Collection<O> result = null;
try {
    if (a != null)
        result = a.getClass().newInstance();
    else
        result = b.getClass().newInstance();
...
ListmergeCollections(Collection... inCollections)
merge Collections
return addCollections(false, inCollections);