By List<? extends Animal> we're saying: " I can be assigned a collection that a subtype of List and typed for<Animal> or anything extends Animal. And oh yes, I SWEAR that will not ADD anything into the collection."
When I tried this, providing Shape isn't an abstract class, both draw functions behaved exactly the same.
When you use the < ? super ...> syntax, you are telling the compiler that you can accept the type on the right hand side of super or any of it supertypes, ...
A List<? super String> may contain lists of type String and any higher type.
But you can add directly only Strings, nothing higher.
When it is used for evil, then watch out! When it is used for good, then things are much nicer. Like this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koophttps://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton