Code example for Collection

Methods: size, toArray

0
     */ 
    @SuppressWarnings("unchecked") 
    public static <T> T[] toArray(Class<T> clazz, Collection<T> any) {
        // --- java is not really supporting a generic array creation 
        // we have to work around it.. 
        T[] ts = (T[]) Array.newInstance(clazz, any.size());
 
        return any.toArray(ts);
    } 
 
    /** 
     * Returns parameterized any to its own array 
     * 
     * @param <T> 
     * @param any 
     * @return 
     */ 
    public static <T> T[] toArray(T... any) {
        return any;
    }