code: public void shrinkTo(int newSize) {
      if (newSize < this.size) {
        for (int i = this.size; i > newSize; i--)
          this.elements[i - 1] = null;
        this.size = newSize;
      }
    }
docs: Shrinks the vector to a given size if the new size is less then the current size.  Otherwise the size remains
  the same.
  @param newSize the new size