title: Can I have a list of 2 inherited types of classes in java?
body: <p>I have  class Parent and a subclass Child. I want to make an ArrayList where I can store objects of both these classes. 
  Is something like that possible?</p>
  
  <p>I tried following:</p>
  
  <pre><code>ArrayList&lt;Parent&gt; list= new ArrayList&lt;Parent&gt;();
  Parent a;
  Parent b;
  Child c;
  list.add(a);
  list.add(b);
  list.add(c);
  </code></pre>
  
  <p>To this point the compiler didn't get me any errors, so I suppose it is ok. But when i try to use a method from Child on an object that i got from the ArrayList I am not able to use it!
  While</p>
  
  <pre><code>list.get(2).countNumbers(); 
  </code></pre>
  
  <p>This gets me an error, the method countNumbers is in Child.I am very confused, thank you in advance!</p>