Here you can find the source of concatenate(List
Parameter | Description |
---|---|
lists | Multiple lists which will be concatenated. |
T | Type of list values. |
@SafeVarargs public static <T> List<T> concatenate(List<T>... lists)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { /**/*from ww w .jav a 2 s . c o m*/ * Concatenates multiple lists into one new list. * * @param lists Multiple lists which will be concatenated. * @param <T> Type of list values. * @return A list containing all values from the given lists. */ @SafeVarargs public static <T> List<T> concatenate(List<T>... lists) { if (lists == null) return new ArrayList<>(); List<T> result = new ArrayList<>(); for (List<T> l : lists) { if (l != null) result.addAll(l); } return result; } }