Better way to write generic method to convert List> to T[][]
Since you are creating new instance of arrays in your second loop, you don't need to know the size of the "inner list". Your "outer array" has to be as big as the "outer list". In a second phase, you instanciate the "inner arrays".

There's a simple way do this:

public &lt;T&gt; T[][] multiListToArray(final List&lt;List&lt;T&gt;&gt; listOfList, final Class&lt;T&gt; classz) {
    final T[][] array = (T[][]) Array.newInstance(classz, listOfList.size(), 0);

    for (int i = 0; i &lt; listOfList.size(); i++) {
        array[i] = listOfList.get(i).toArray((T[]) Array.newInstance(classz, listOfList.get(i).size()));
    }

    return array;
}


More over, as you can see in the code above, you can provide a 0-length array to toArray(T[]) method.

This piece of code:

final List&lt;List&lt;String&gt;&gt; test = new ArrayList&lt;List&lt;String&gt;&gt;();
test.add(new ArrayList&lt;String&gt;(Arrays.asList("a", "b", "c")));
test.add(new ArrayList&lt;String&gt;(Arrays.asList("d", "e", "f", "g")));
test.add(new ArrayList&lt;String&gt;(Arrays.asList("h", "i")));

for (final String[] innerArray : multiListToArray(test, String.class)) {
    System.out.println(Arrays.toString(innerArray));
}


Will produce this output:


  [a, b, c]
  [d, e, f, g]
  [h, i]


EDIT: There is an Ideone example.

EDIT 2: Code and Ideone updated to comply with OP needs.