Copies an iterable's elements into an array. @param iterable the iterable to copy @param type the type of the elements @return a newly-allocated array into which all the elements of the iterable have been copied
(
Iterable<? extends T> iterable, Class<@NonNull T> type)
| 286 | * @return a newly-allocated array into which all the elements of the iterable have been copied |
| 287 | */ |
| 288 | @GwtIncompatible // Array.newInstance(Class, int) |
| 289 | public static <T extends @Nullable Object> T[] toArray( |
| 290 | Iterable<? extends T> iterable, Class<@NonNull T> type) { |
| 291 | return toArray(iterable, ObjectArrays.newArray(type, 0)); |
| 292 | } |
| 293 | |
| 294 | static <T extends @Nullable Object> T[] toArray(Iterable<? extends T> iterable, T[] array) { |
| 295 | Collection<? extends T> collection = castOrCopyToCollection(iterable); |