src/main/java/org/organicdesign/fp/collections/Cowry.java
public static <T> T[] arrayCopy(T[] items, int length, Class<T> tClass) {
        // Make an array of the appropriate size.  It's too bad that the JVM bothers to
        // initialize this with nulls.
        @SuppressWarnings("unchecked")
        T[] newItems = (T[]) ((tClass == null) ? new Object[length]
                                               : Array.newInstance(tClass, length) );

        // array-copy the items up to the new length.
        if (length > 0) {
            System.arraycopy(items, 0, newItems, 0,
                             items.length < length ? items.length
                                                   : length);
        }
        return newItems;
    }
public static <T> T[] arrayCopy(T[] items, int length, Class<T> tClass) {
        // Make an array of the appropriate size.  It's too bad that the JVM bothers to
        // initialize this with nulls.
        @SuppressWarnings("unchecked")
        T[] newItems = (T[]) ((tClass == null) ? new Object[length]
                                               : Array.newInstance(tClass, length) );

        // array-copy the items up to the new length.
        if (length > 0) {
            System.arraycopy(items, 0, newItems, 0,
                             items.length < length ? items.length
                                                   : length);
        }
        return newItems;
    }
public static < T > T [ ] arrayCopy ( T [ ] items , int length , Class < T > tClass ) { // Make an array of the appropriate size.  It's too bad that the JVM bothers to // initialize this with nulls. @ SuppressWarnings ( "unchecked" ) T [ ] newItems = ( T [ ] ) ( ( tClass == null ) ? new Object [ length ] : Array . newInstance ( tClass , length ) ) ; // array-copy the items up to the new length. if ( length > 0 ) { System . arraycopy ( items , 0 , newItems , 0 , items . length < length ? items . length : length ) ; } return newItems ; }
Returns a new array containing the first n items of the given array.

@param items the items to copy
@param length the maximum length of the new array
@param tClass the class of the items in the array (null for Object)
@return a copy of the original array with the given length
Returns a new array containing the first n items of the given array .