Here you can find the source of newArrayListSized(Iterable> fromSize)
public static <T> ArrayList<T> newArrayListSized(Iterable<?> fromSize)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Collection; public class Main { /**//from w ww . j a va 2s . c om * Creates a new ArrayList which if possible is sized the same as the passed in * iterable (ie only if it is actually a Collection). */ public static <T> ArrayList<T> newArrayListSized(Iterable<?> fromSize) { if (fromSize instanceof Collection<?>) return new ArrayList<T>(((Collection<?>) fromSize).size()); else return new ArrayList<T>(); } }