public static < T , C extends Collection < ? super T > > C toCollection ( Iterable < T > iterable , C collection ) { Objects . requireNonNull ( iterable , "The iterable is null" ) ; Objects . requireNonNull ( collection , "The collection is null" ) ; return Iterators . toCollection ( iterable . iterator ( ) , collection ) ; }
Drains all elements that are provided by the iterator of the given iterable into the given collection