I have a class who relies on generics to bind types internally.
class C<T1, T2 extends T1> {
T1 e1;
T2 e2;
/* stuff */
}
In my code I know that, while c.e1
and c.e2
might not have the same class, c.e2
is an instance of a subclass of the class of c.e1
.
I need to create a List
of these c
s, and those elements would not share a common base class. Still, I want to preserve the fact that each element of the List
has the attributes bounded between each other.
Ideally I would like to create a List<C<?, ? extends ...>>
"but" I don't know any syntax to specify this behaviour.
And using a List<C<?, ?>>
it seems to me I lost the generics types.
What is the correct way to do this collection?