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