Java tutorial
//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)); } }