title: Is List<Dog> a subclass of List<Animal>? Why are Java generics not implicitly polymorphic?
body: <p>I'm a bit confused about how Java generics handle inheritance / polymorphism.</p>
  
  <p>Assume the following hierarchy -</p>
  
  <p><strong>Animal</strong> (Parent)</p>
  
  <p><strong>Dog</strong> - <strong>Cat</strong> (Children)</p>
  
  <p>So suppose I have a method <code>doSomething(List&lt;Animal&gt; animals)</code>. By all the rules of inheritance and polymorphism, I would assume that a <code>List&lt;Dog&gt;</code> <em>is</em> a <code>List&lt;Animal&gt;</code> and a <code>List&lt;Cat&gt;</code> <em>is</em> a <code>List&lt;Animal&gt;</code> - and so either one could be passed to this method. Not so. If I want to achieve this behavior, I have to explicitly tell the method to accept a list of any subclass of Animal by saying <code>doSomething(List&lt;? extends Animal&gt; animals)</code>. </p>
  
  <p>I understand that this is Java's behavior. My question is <em>why</em>? Why is polymorphism generally implicit, but when it comes to generics it must be specified?</p>