2

Why has java decided to throw an ArrayStoreException in the following method <A> A[] Stream<T>.toArray(IntFunction<A[]>) if the runtime type of any of the stream elements isn't a subtype of the runtime type of the array.

Instead, if the generic type A was bounded like in the following <A super T> A[] Stream<T>.toArray (IntFunction<A[]>) this will remove the necessity of throwing the exception above and being checked at compile time.

marsouf
  • 1,107
  • 8
  • 15

0 Answers0