I read a couple of posts such as here but I was unable to find the solution for my problem.
Why I am unable to add d? It is a subtype of Object...
Type of d: A<B<X>>
List<A<B<? extends Object>>> rv=new LinkedList<>();
rv.add(d); //not working
EDIT
I tried to simplify the problem. When I do:
A<B<?>> abcv=new A<B<String>>();
I get the error: Type mismatch: cannot convert from A<B<String>> to A<B<?>>
However, String is compatible with "?" - so why is it not working? I want to add elements to a list where the last type can by anything, something like this:
List<A<B<?>>> rv=new LinkedList<>();
rv.add(new A<B<X>>());
rv.add(new A<B<String>>());
rv.add(new A<B<Integer>>());
A<B<? extends Object>>. This should be enough. What do you mean by "not working"?? extends Objectcan contain something of typeX. It could be something else entirely likeA<B<String>>.<? extends Object>is the same as<?>.