Originally posted by Brian Legg:
Rob... you said, "- "? super X" allows you to add anything that IS-A X, but you can only retrieve as Object (without casts)"
Shouldn't that say that "? super X" allows you to add anything that X IS-A, not IS-A X? I mean replace X with Dog and if you add Animal that that's ok because Animal is a super class of Dog, but "Animal IS-A Dog" is not necessarily true.
Any help appreciated.
If X is Dog, surely you can't add an Animal. The actual type can still be Dog - the super (and extends) are a bit misleading. And adding Animals to a List of Dogs is dangerous. What if the Animal is a Cat?! DISASTER!
Like I said, any
object that IS-A Dog (a.k.a. any object for which "instanceof Dog" returns true) can be added. I'm just using the terms IS-A and HAS-A because a lot of people are acquainted with those.