title: Polymorphism: Why use "List list = new ArrayList" instead of "ArrayList list = new ArrayList"?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/147468/why-should-the-interface-for-a-java-class-be-prefered">Why should the interface for a Java class be prefered?</a>  </p>
  </blockquote>
  
  
  
  <p>When should I use </p>
  
  <pre><code>List&lt;Object&gt; list = new ArrayList&lt;Object&gt;();
  </code></pre>
  
  <p><code>ArrayList</code> inherits from <code>List</code>, so if some features in <code>ArrayList</code> aren't in <code>List</code>, then I will have lost some of the features of <code>ArrayList</code>, right? And the compiler will notice an error when trying to access these methods?</p>