question: public static Object toArray ( Collection < ? > collection , Class < ? > componentType ) { if ( componentType . isPrimitive ( ) ) { Object array = Array . newInstance ( componentType , collection . size ( ) ) ; int index = 0 ; for ( Object value : collection ) { Array . set ( array , index ++ , value ) ; } return array ; } return collection . toArray ( ( Object [ ] ) Array . newInstance ( componentType , collection . size ( ) ) ) ; }
target:  Returns a new array of the given component type (possibly a Java primitive) that is a copy of the content of the given collection.