@ SuppressWarnings ( "unchecked" ) public static < T > T [ ] toArray ( T [ ] source , Collection < ? extends T > newContent ) { final Object array = Array . newInstance ( source . getClass ( ) . getComponentType ( ) , newContent . size ( ) ) ; int i = 0 ; for ( final T element : newContent ) { Array . set ( array , i , element ) ; ++ i ; } return ( T [ ] ) array ; }
Convert to an array .