Java tutorial
//package com.java2s; //License from project: Apache License import java.util.Collection; import java.util.LinkedList; import java.util.List; public class Main { public static <E> List<E> flatten(Collection<? extends Collection<E>> nested) { List<E> flat = new LinkedList<>(); for (Collection<E> current : nested) { flat.addAll(current); } return flat; } }