Can any body explain me how
polymorphism works with generics pbly with a good example and the minor glitches to remember for the SCJP6 exam ?
Also pl correct me if I am wrong...
You can in no way add to the collection using the wild card notation the subtypes of the types you specified as part of your signature
but
you can just allow to pass them(subtypes) as a actual parameter into the method signature....say for example
is a method.
you can call this method saying addme ( Doglist ) where doglist is a list of type Dog ...but you cannot actually add the elements of type dog to this collection where it actually expects the elements to be of type animal and only animal.
And if I am right in this, my question is in what cases do we use this kind of scenarios wherein we can just pass in as part of the method arguments but we cannot actually ADD anything of the subtype or the super type into the collection. I mean how is this concept being used in the real world
java programes...I am new to java programming so pl bare with me if I ask petty issues.