Here you can find the source of concat(final Collection
Parameter | Description |
---|---|
collections | The collection(s). |
@SafeVarargs public static <T> List<T> concat(final Collection<T>... collections)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { /**// ww w . ja va 2 s. c o m * Concatenates all the given {@code collections} together (order is conserved). * <p/> * <pre> * concat({4,5}, {1,6}, {7,9}) -> {4,5,1,6,7,9} * concat({4,5}, null, {7,9}) -> {4,5,7,9} * </pre> * * @param collections * The collection(s). * @return The given {@code collections} concatenated together. */ @SafeVarargs public static <T> List<T> concat(final Collection<T>... collections) { final List<T> concatenation = new ArrayList<T>(); for (final Collection<T> collection : collections) { if (collection != null) { concatenation.addAll(collection); } } return concatenation; } }