Java List Concatenate concat(List collection1, List collection2)

Here you can find the source of concat(List collection1, List collection2)

Description

concat

License

Open Source License

Declaration

public static <T> List<T> concat(List<T> collection1, List<T> collection2) 

Method Source Code

//package com.java2s;

import java.util.Collection;

import java.util.List;
import java.util.Map;

public class Main {

    public static <T> List<T> concat(List<T> collection1, List<T> collection2) {
        if (isEmpty(collection1)) {
            return collection2;
        }/*ww w. ja  v a  2 s .  co  m*/
        if (isEmpty(collection2)) {
            return collection1;
        }

        collection1.addAll(collection2);
        return collection1;

    }

    public static boolean isEmpty(Map<?, ?> map) {
        return (map == null) || (map.size() == 0);
    }

    public static boolean isEmpty(Collection<?> collection) {
        return (collection == null) || (collection.size() == 0);
    }
}

Related

  1. concat(List tokens)
  2. concat(List words)
  3. concat(List... lists)
  4. concat(List lista, String sep, StringBuilder destino)
  5. concat(List a, List b)
  6. concat(List l1, List l2)
  7. concat(List list, T... items)
  8. concatAddresses(List addresses)
  9. concatAll(final T[] empty, Iterable arrayList)