concat Lists - Java Collection Framework

Java examples for Collection Framework:List

Description

concat Lists

Demo Code


//package com.java2s;

import java.util.LinkedList;
import java.util.List;

public class Main {
    public static <T> List<T> concatLists(Iterable<? extends T>... lists) {
        final List<T> result = new LinkedList<T>();
        for (final Iterable<? extends T> list : lists) {
            for (final T item : list) {
                result.add(item);/*from   w ww . j  av  a2 s.c  om*/
            }
        }
        return result;
    }
}

Related Tutorials