public static <T> T[] asArray(Collection<T> items, Class<T> elementType) {
        if (items == null) {
            return null;
        }
        @SuppressWarnings("unchecked")
        T[] results = (T[]) Array.newInstance(elementType, items.size());
        int i = 0;
        for (T item : items) {
            results[i++] = item;
        }
        return results;
    }
public static <T> T[] asArray(Collection<T> items, Class<T> elementType) {
        if (items == null) {
            return null;
        }
        @SuppressWarnings("unchecked")
        T[] results = (T[]) Array.newInstance(elementType, items.size());
        int i = 0;
        for (T item : items) {
            results[i++] = item;
        }
        return results;
    }
public static < T > T [ ] asArray ( Collection < T > items , Class < T > elementType ) { if ( items == null ) { return null ; } @ SuppressWarnings ( "unchecked" ) T [ ] results = ( T [ ] ) Array . newInstance ( elementType , items . size ( ) ) ; int i = 0 ; for ( T item : items ) { results [ i ++ ] = item ; } return results ; }
-----------------------------------------------------------------------
-----------------------------------------------------------------------