J
Joona I Palaste
The generics introduced in Java 1.5 are quite an interesting concept,
when it comes to inheritance. I therefore have a question:
Suppose both SuperList and SubList are template-able (or what is the
correct term?) collections and SubList is a subclass of SuperList.
Further suppose SubElement is a subclass of SuperElement but these don't
have anything to do (inheritance-wise) with the two list classes above.
Is SubList<SubElement> now a subtype of both SuperList<SubElement> and
SubList<SuperElement>? Is it a subtype of SuperList<SuperElement>?
What about SubList<SuperElement> and SuperList<SubElement>, is either a
subtype of the other?
In general, if FoobarList is a template-able collection, is
FoobarList<A> a subtype of FoobarList, no matter what class A is?
when it comes to inheritance. I therefore have a question:
Suppose both SuperList and SubList are template-able (or what is the
correct term?) collections and SubList is a subclass of SuperList.
Further suppose SubElement is a subclass of SuperElement but these don't
have anything to do (inheritance-wise) with the two list classes above.
Is SubList<SubElement> now a subtype of both SuperList<SubElement> and
SubList<SuperElement>? Is it a subtype of SuperList<SuperElement>?
What about SubList<SuperElement> and SuperList<SubElement>, is either a
subtype of the other?
In general, if FoobarList is a template-able collection, is
FoobarList<A> a subtype of FoobarList, no matter what class A is?