How to build an array of ArrayList<Integer> in Java? : <p>I wrote a piece of code like this  </p>

<pre><code>ArrayList&lt;Integer&gt;[]list=new ArrayList&lt;Integer&gt;[128];
</code></pre>

<p>But Eclipse says </p>

<blockquote>
  <p>Cannot create a generic array of ArrayList</p>
</blockquote>

<p>I also tried code like this  </p>

<pre><code>ArrayList&lt;Integer&gt;[]list=(ArrayList&lt;Integer&gt;[])new Object[128];
</code></pre>

<p>But Eclipse throws exception:</p>

<blockquote>
  <p>[Ljava.lang.Object; cannot be cast to [Ljava.util.ArrayList;</p>
</blockquote>

<p>So how can I build an array of ArrayList&lt; Integer > ?</p>

<p>Thanks a lot!!</p>
