public static Object convertToArray ( final Class type , final List < ? > values ) { final Object exampleArray = Array . newInstance ( type , values . size ( ) ) ; try { return values . toArray ( ( Object [ ] ) exampleArray ) ; } catch ( ClassCastException e ) { for ( int i = 0 ; i < values . size ( ) ; i ++ ) { Array . set ( exampleArray , i , values . get ( i ) ) ; } return exampleArray ; } }
Converts a List to an array