Java List Concatenate concatenate(List... lists)

Here you can find the source of concatenate(List... lists)

Description

Concatenates multiple lists into one new list.

License

Open Source License

Parameter

Parameter Description
lists Multiple lists which will be concatenated.
T Type of list values.

Return

A list containing all values from the given lists.

Declaration

@SafeVarargs
public static <T> List<T> concatenate(List<T>... lists) 

Method Source Code


//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;
    }
}

Related

  1. concatenate(List list)
  2. concatenate(List strings)
  3. concatenate(List xs)
  4. concatenate(List a, List b)
  5. concatenate(List contents, String separator)
  6. concatenate(String[] selectors, List lessExtends)
  7. concatenateFileContent(List fileContents)
  8. ConcatenateInt(List arrays)
  9. concatenateList(List values)