posted 18 years ago
In the code below I was surprised that I couldn't add an Animal to the List at the line indicated in the comment.
Can anyone clarify the rules here? From what I could see it is legal to pass any kind of list of objects where these objects are Dogs or supertypes of Dog, but it is only legal to add an actual Dog to the list.
So where we say ? super <class> can I assum the general rule that I can only add <class> objects to the collection even though the collection may be typed on a super type?
Or has something else gone wrong?
Thanks,
Tom