This function converts a 2-dimensional Collection
of String
s to a 2-dimensional array of String
s:
public static String[][] toArray(
Collection<? extends Collection<String>> values){
String[][] result = new String[ values.size() ][];
int i=0;
for( Collection<String> row : values ){
result[i] = row.toArray( new String[ row.size() ] );
i++;
}
return result;
}
How would this function be written in order to do this generically:
public static <X> X[][] ArrayArray(Collection<? extends Collection<X>> values){
// ?
}