Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.ArrayList;

import java.util.List;

public class Main {
    /**
     * Joins the items of multiple lists into one list.
     * 
     * @return
     */
    public static <GPItem> List<GPItem> joinLists(final List<List<GPItem>> lists) {
        if (lists.size() == 0) {
            return new ArrayList<GPItem>(0);
        }
        final List<GPItem> joined = new ArrayList<GPItem>(lists.size() * lists.get(0).size());
        for (final List<GPItem> list : lists) {
            joined.addAll(list);
        }

        return joined;
    }
}