public void resize ( int newSize ) { if ( newSize > elements . length ) { reallocate ( Math . max ( newSize , 2 * elements . length ) ) ; } else { for ( int i = size ; i < newSize ; i ++ ) { elements [ i ] = 0 ; } } size = newSize ; }
Resizes the array to the specified length truncating or zero - padding the array as necessary .