Here you can find the source of concat(Collection
public static <T> Collection<T> concat(Collection<T>... collections)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; public class Main { public static <T> Collection<T> concat(Collection<T>... collections) { if (collections == null || collections.length == 0) { return Collections.emptyList(); }//from w w w .j av a 2 s. co m if (collections.length == 1) { return collections[0]; } return concat(Arrays.asList(collections)); } public static <T> Collection<T> concat(Collection<? extends Collection<T>> collections) { int size = 0; for (Collection<T> c : collections) { if (c != null) { size += c.size(); } } List<T> result = new ArrayList<T>(size); for (Collection<T> c : collections) { if (c != null) { result.addAll(c); } } return result; } }