code: public int[] trimAndGet() {
      if (size < elementData.length) {
        elementData = Arrays.copyOf(elementData, size);
      }
      return elementData;
    }
docs: Trims the capacity of this <tt>IntArrayList</tt> instance to be the
  list's current size and return the internal array. An application can use this operation to minimize
  the storage of an <tt>IntArrayList</tt> instance.