I\'d never heard about wildcars until a few days ago and after reading my teacher\'s Java book, I\'m still not sure about what\'s it for and why would I need to use it.
Java generics are invariant.
Suppose we have B extends A:
B is a subtype of Ainstanceof B is also an instanceof ASince Java arrays are covariant:
B[] is a subtype of A[]instanceof B[] is also an instanceof A[]However, Java generics are invariant:
Wildcards are used to make it more flexible while preserving type safety.
List is a List extends A>