public static < T > T [ ] append ( T [ ] array , int currentSize , T element ) { assert currentSize <= array . length ; if ( currentSize + 1 > array . length ) { @ SuppressWarnings ( "unchecked" ) T [ ] newArray = ( T [ ] ) new Object [ growSize ( currentSize ) ] ; System . arraycopy ( array , 0 , newArray , 0 , currentSize ) ; array = newArray ; } array [ currentSize ] = element ; return array ; }
Appends an element to the end of the array growing the array if there is no more room .