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 {
    /**
     * Flattens the provided list into a single list.
     * 
     * @param lists
     * @return
     */
    public final static <V> List<V> flatten(final List<List<V>> lists) {

        int size = 0;

        for (final List<V> list : lists) {
            size += list.size();
        }

        final List<V> res = new ArrayList<V>(size);

        for (final List<V> list : lists) {
            res.addAll(list);
        }

        return res;

    }
}