code: @SuppressWarnings("unchecked")
      public <A> A[] toArray(Class<A> elementClass) {
          return stream().toArray(size -> (A[])Array.newInstance(elementClass, size));
      }
docs: Returns an array containing all the stream elements using the supplied
  element type class to allocate an array.
  
  <p>
  This is a <a href="package-summary.html#StreamOps">terminal</a>
  operation.
  
  @param <A> the element type of the resulting array
  @param elementClass the type of array elements
  @return an array containing the elements in this stream
  @throws ArrayStoreException if the runtime type of the array returned
  from the array generator is not a supertype of the runtime type
  of every element in this stream
  @see #toArray(java.util.function.IntFunction)
  @since 0.6.3