title: How to properly cast nested generic types in Java
body: <p>In Java I can cast:</p>
  
  <pre><code>List&lt;?&gt; j = null;
  List&lt;Integer&gt; j2 = (List&lt;Integer&gt;)j;
  </code></pre>
  
  <p>So why does the following fail?</p>
  
  <pre><code>List&lt;List&lt;?&gt;&gt; i = null;
  List&lt;List&lt;Integer&gt;&gt; i2 = (List&lt;List&lt;Integer&gt;&gt;)i;
  </code></pre>