code: public synchronized void trimToSize() {
          modCount++;
          int oldCapacity = elementData.length;
          if (elementCount < oldCapacity) {
              elementData = Arrays.copyOf(elementData, elementCount);
          }
      }
docs: Trims the capacity of this vector to be the vector's current
  size. If the capacity of this vector is larger than its current
  size, then the capacity is changed to equal the size by replacing
  its internal data array, kept in the field {@code elementData},
  with a smaller one. An application can use this operation to
  minimize the storage of a vector.