code: 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;
    }
docs: Resizes the array to the specified length, truncating or zero-padding the
  array as necessary.
  
  @param newSize
  The new size of the array.