question: protected void expandFor ( int index , Object d ) { if ( index < size ) return ; int oldSize = size , capacity = vector . length ; size = index + 1 ; if ( capacity >= size ) return ; while ( capacity < size ) capacity *= 2 ; Object [ ] t = new Object [ capacity ] ; System . arraycopy ( vector , 0 , t , 0 , oldSize ) ; if ( d != null ) Arrays . fill ( t , oldSize , size , d ) ; vector = t ; }
target:  Makes sure the capacity and size of the vector can accomodate the given index. The capacity of the vector is simply doubled until it can accomodate its size.