public T[] ensureCapacity(int additionalCapacity){
  int sizeNeeded=size + additionalCapacity;
  if (sizeNeeded >= items.length)   resize(Math.max(8,sizeNeeded));
  return items;
}

public T [ ] ensureCapacity ( int additionalCapacity ) { int sizeNeeded = size + additionalCapacity ; if ( sizeNeeded >= items . length ) resize ( Math . max ( 8 , sizeNeeded ) ) ; return items ; }
increases the size of the backing array to acommodate the specified number of additional items . useful before adding many items to avoid multiple backing array resizes .
