Code example for Collection

Methods: sizetoArray

    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;
Stop searching for code, let great code find you!  Add Codota to your java IDE