title: Why should the interface for a Java class be preferred?
body: <p><a href="https://pmd.github.io/" rel="noreferrer">PMD</a> would report a violation for:</p>
  
  <pre><code>ArrayList&lt;Object&gt; list = new ArrayList&lt;Object&gt;();
  </code></pre>
  
  <p>The violation was "Avoid using implementation types like 'ArrayList'; use the interface instead".</p>
  
  <p>The following line would correct the violation:</p>
  
  <pre><code>List&lt;Object&gt; list = new ArrayList&lt;Object&gt;();
  </code></pre>
  
  <p>Why should the latter with <code>List</code> be used instead of <code>ArrayList</code>?</p>