static < T > T [ ] toArrayImpl ( Collection < ? > c , T [ ] array ) { int size = c . size ( ) ; if ( array . length < size ) { array = newArray ( array , size ) ; } fillArray ( c , array ) ; if ( array . length > size ) { array [ size ] = null ; } return array ; }
Returns an array containing all of the elements in the specified collection ; the runtime type of the returned array is that of the specified array . If the collection fits in the specified array it is returned therein . Otherwise a new array is allocated with the runtime type of the specified array and the size of the specified collection .