Copies an iterator's elements into an array. The iterator will be left exhausted: its {@code hasNext()} method will return {@code false}. @param iterator the iterator to copy @param type the type of the elements @return a newly-allocated array into which all the elements of the iterator have been c
(
Iterator<? extends T> iterator, Class<@NonNull T> type)
| 348 | * @return a newly-allocated array into which all the elements of the iterator have been copied |
| 349 | */ |
| 350 | @GwtIncompatible // Array.newInstance(Class, int) |
| 351 | public static <T extends @Nullable Object> T[] toArray( |
| 352 | Iterator<? extends T> iterator, Class<@NonNull T> type) { |
| 353 | List<T> list = Lists.newArrayList(iterator); |
| 354 | return Iterables.<T>toArray(list, type); |
| 355 | } |
| 356 | |
| 357 | /** |
| 358 | * Adds all elements in {@code iterator} to {@code collection}. The iterator will be left |