title: How to call a method with List<Child>, but method's parameter is List<Parent>?
body: <p>I am having some problem, and I can't understand why it isn't working.
  I have a Parent class:</p>
  
  <pre><code>public abstract class Parent {
      ...
  }
  </code></pre>
  
  <p>and 2 Child classes:</p>
  
  <pre><code>public class Child1 extends Parent {
      ...
  }
  
  public class Child2 extends Parent {
      ...
  }
  </code></pre>
  
  <p>I have a method, which is working with the children list. But it should work with both type Child1 and Child2, so I thought it should work:</p>
  
  <pre><code>public static void doSomething(List&lt;Parent&gt; list) {
      ...
  }
  </code></pre>
  
  <p>and this is how I call it:</p>
  
  <pre><code>List&lt;Child1&gt; children = dao.getChildren("1");
  doSomething(children);
  
  List&lt;Child2&gt; children2 = dao.getChildren("2");
  doSomething(children2);
  </code></pre>
  
  <p>But it doesn't work, it shows this error:</p>
  
  <pre><code>The method doSomething(List&lt;Parent&gt;) in the type MyClass is not applicable for the arguments (List&lt;Child1&gt;)
  The method doSomething(List&lt;Parent&gt;) in the type MyClass is not applicable for the arguments (List&lt;Child2&gt;)
  </code></pre>
  
  <p>How could I write this code?</p>