Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.Collection; public class Main { /** * 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()]); } }