Matthew Brown wrote:When you say ? super Cat, in could contain anything above Cat in the hierarchy. In other words, it could be an Object. So there's no way you can safely cast things to a Cat and call methods (unless you do it yourself, explicitly).
? super Cat comes in useful when you want to add things to the collection. It's saying "you can safely put any Cat you want in here". Whereas ? extends Cat means "everything in here is definitely a Cat". These aren't the same thing.
Hello Matthew Brown,
Thanks for the quick reply.
i was just wondering if theres any way. and how can we do the casting explicitly in this senario. any idea /.?
thanks