code: public synchronized void setSize(int newSize) {
          modCount++;
          if (newSize > elementCount) {
              ensureCapacityHelper(newSize);
          } else {
              for (int i = newSize ; i < elementCount ; i++) {
                  elementData[i] = null;
              }
          }
          elementCount = newSize;
      }
docs: Sets the size of this vector. If the new size is greater than the
  current size, new {@code null} items are added to the end of
  the vector. If the new size is less than the current size, all
  components at index {@code newSize} and greater are discarded.
  
  @param  newSize   the new size of this vector
  @throws ArrayIndexOutOfBoundsException if the new size is negative