code: public Object toArray(Object a) {
  
          if (Array.getLength(a) < elementCount) {
              a = Array.newInstance(a.getClass().getComponentType(),
                                    elementCount);
          }
  
          System.arraycopy(elementData, 0, a, 0, elementCount);
  
          return a;
      }
docs: Copies all elements of the list to a[]. It is assumed a[] is of the
  correct type. If a[] is too small, a new array or the same type is
  returned. If a[] is larger, only the list elements are copied and no
  other change is made to the array.
  Differs from the implementation in java.util.ArrayList in the second
  aspect.