title: Array of Generic List
body: <p>I am playing with Generic and arrays, it seems the following code compiles fine,</p>
  
  <pre><code>ArrayList&lt;Key&gt; a = new ArrayList&lt;Key&gt;();
  </code></pre>
  
  <p>But the compiler complains about this one,</p>
  
  <pre><code>ArrayList&lt;Key&gt;[] a = new ArrayList&lt;Key&gt;[10];
  </code></pre>
  
  <p>By reading post in stackoverflow, I sort of understand that this is due to Type Erasure and I can fix it by using, </p>
  
  <pre><code>ArrayList&lt;Key&gt;[] a = (ArrayList&lt;Key&gt; []) new ArrayList[10];
  </code></pre>
  
  <p>or list of list</p>
  
  <pre><code>ArrayList&lt;ArrayList&lt;Key&gt;&gt; b = new ArrayList&lt;ArrayList&lt;Key&gt;&gt;();
  </code></pre>
  
  <p>But I can't figure out the reason behind the scene. Especially, why the second one is illegal given the first one is perfectly OK. And why the compiler does not complain about the list of list.</p>