title: Warning unnecessary with generic collections?
body: <p>I wonder why Java compiler doesn't trust in this line of code :</p>
  
  <pre><code>List&lt;Car&gt; l = new ArrayList();
  </code></pre>
  
  <p>and expects to have a typed ArrayList : </p>
  
  <pre><code>List&lt;Car&gt; l = new ArrayList&lt;Car&gt;();
  </code></pre>
  
  <p>Indeed, compiler indicates an unchecked assignment with the first case.</p>
  
  <p>Why doesn't compiler see that this ArrayList() has just been created and so it's impossible to find already in it some objects other than 'Car'?</p>
  
  <p>This warning would make sense if the untyped ArrayList was created before but doesn't in this case ...</p>
  
  <p>Indeed, since List is typed as 'Car', all futures "l.add('object')" will be allowed only if 'object' is a 'Car'.  => So, according to me, no surprise could happen.</p>
  
  <p>Am I wrong ?</p>
  
  <p>Thanks     </p>