Here you can find the source of flatten( Collection
public static <T, C extends Collection<T>> List<T> flatten( Collection<C> colOfCols)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static <T, C extends Collection<T>> List<T> flatten( Collection<C> colOfCols) { int size = 0; for (C col : colOfCols) { size += col.size();//from www .ja v a 2s . c om } ArrayList<T> list = new ArrayList<T>(size); for (C col : colOfCols) { list.addAll(col); } return list; } }