Here you can find the source of toArray(Collection
Parameter | Description |
---|---|
collection | the collection to cast |
T | the type of the collection contents |
public static <T> T[] toArray(Collection<T> collection)
//package com.java2s; //License from project: Open Source License import java.util.Collection; public class Main { /**// www . ja v a 2s . c o m * Cast a collection to an array * * @param collection the collection to cast * @param <T> the type of the collection contents * @return an array of type T */ public static <T> T[] toArray(Collection<T> collection) { return (T[]) collection.toArray(new Object[collection.size()]); } }