title: Cast the sub class List to base class List
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2745265/is-listdog-a-subclass-of-listanimal-why-arent-javas-generics-implicit">Is <code>List&lt;Dog&gt;</code> a subclass of <code>List&lt;Animal&gt;</code>? Why aren&#39;t Java&#39;s generics implicitly polymorphic?</a>  </p>
  </blockquote>
  
  
  
  <p>I have a List of class <strong>Dogs</strong> which extends <strong>Animals</strong> and have a List of the following type.</p>
  
  <pre><code>ArrayList&lt;Animals&gt; animal = new ArrayList&lt;Animals&gt;();
  </code></pre>
  
  <p>Now I have another class, <strong>Puppy</strong>, which extends Dogs.</p>
  
  <p>And have a <code>List&lt;Puppy&gt; puppy = new ArrayList&lt;Puppy&gt;();</code></p>
  
  <p>Now I want to cast list <code>animal</code> to <code>puppy</code>. Is it possible to do directly?</p>
  
  <p>I can do it as below.</p>
  
  <pre><code>for (Animals ani: animal){
       puppy.add((Puppy) ani)
  }
  </code></pre>
  
  <p>But I want a direct casting solution. Is it possible?</p>