title: Using generics in ArrayList (Java, "cannot be applied" error)
body: <p>In my Android Studio project I have simple structure of classes:</p>
  
  <pre><code>public class P{}
  
  public class A extends P{}
  
  public class B extends P{}
  </code></pre>
  
  <p>And in another class I have a List:</p>
  
  <pre><code>private List&lt;? extends P&gt; data;
  private List&lt;A&gt; listA;
  private List&lt;B&gt; listB;
  </code></pre>
  
  <p>But when I try to do that:</p>
  
  <pre><code>data = listA; //it's ok
  data.addAll(listB); //it calls error
  </code></pre>
  
  <p>The second line is red in Android Studio and error is:</p>
  
  <pre><code>addAll(java.util.Collection&lt;capture&lt;? extends com.mydomain.P&gt;&gt;) 
  in List cannot be applied to (java.util.List&lt;com.mydomain.subclass.B&gt;)
  </code></pre>
  
  <p>How can I solve this problem?</p>