Attempting to assign the array turned by ReferenceArrayList::elements to K[]—or anything else other than Object[]—causes a ClassCastException because Object[] cannot be cast to anything except Object[], so either elements should return Object[] instead or the element array should actually be a K[].
Attempting to assign the array turned by
ReferenceArrayList::elements
toK[]
—or anything else other thanObject[]
—causes aClassCastException
becauseObject[]
cannot be cast to anything exceptObject[]
, so eitherelements
should returnObject[]
instead or the element array should actually be aK[]
.