Java tutorial
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.List; public class Main { @SafeVarargs public static <T> ArrayList<T> flattenList(List<T>... instancesList) { int size = 0; for (List<T> list : instancesList) { size += list.size(); } ArrayList<T> flattened = new ArrayList<>(size); for (List<T> list : instancesList) { flattened.addAll(list); } return flattened; } }