title: What could happen when one of the type parameters was not specified during instantiation of a collection?
body: <p>The instantiation of a collection in Java is normally as below:</p>
  
  <pre><code>ArrayList&lt;Integer&gt; ali = new ArrayList&lt;Integer&gt;();
  </code></pre>
  
  <p>It is said that with this convention, certain errors such as</p>
  
  <pre><code>String s = (String)ali(0)
  </code></pre>
  
  <p>Can lead to compile error instead of run time exceptions.</p>
  
  <p>However, I observed that although</p>
  
  <pre><code>ArrayList ali = new ArrayList&lt;Integer&gt;();
  </code></pre>
  
  <p>Will cause the situation above to cause run time exceptions,</p>
  
  <pre><code>ArrayList&lt;Integer&gt; ali = new ArrayList();
  </code></pre>
  
  <p>Will still cause compile time error in the situation above.</p>
  
  <p>Is there something I miss, or could we ignore the type on the right hand side if we do not care for clarity of code?</p>
  
  <p>Thanks!</p>