Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: LGPL 

import java.util.ArrayList;
import java.util.Collection;

import java.util.LinkedHashSet;
import java.util.List;

public class Main {
    public static final <E> List<E> merge(Collection<E>... collections) {
        return flatten(collections);
    }

    public static final <E> List<E> flatten(Collection<?>... collections) {
        List<E> resultList = new ArrayList<>();

        for (Collection<?> collection : collections) {
            resultList.addAll((Collection<? extends E>) collection);
        }

        return new ArrayList<>(new LinkedHashSet<>(resultList));
    }
}