Convert Collection<List<T>> to 2D array T[][]
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/10043209/convert-arraylist-into-2d-array-containing-varying-lengths-of-arrays">Convert ArrayList into 2D array containing varying lengths of arrays</a>  </p>
</blockquote>



<p>How can I convert a <code>Collection&lt;List&lt;Foo&gt;&gt;</code> into a 2D array of type <code>Foo[][]</code>?</p>

<p>I'm trying to use the <code>toArray</code> method, but I'm not sure about the syntax. For instance, this doesn't work:</p>

<pre><code>import com.google.common.collect.Collections2;
Collection&lt;List&lt;Foo&gt;&gt; permuted = Collections2.permutations(bar);
Foo[][] permutedArray = permuted.toArray(new Foo[10][10]);//exception here
</code></pre>

<p>it's throwing <code>ArrayStoreException</code>. In this case, what should be the type for <code>permutedArray</code>?</p>
