Friday, July 1, 2011

Wildcards in Java Generics

What is covariance, contravariance and invariance?
As we've seen in the previous post, the subtyping relation of generic types is invariant. Sometimes, though, we'd like to use generic types in the same way we can use ordinary types:

  • Narrowing a reference (covariance).
  • Widening a reference (contravariance
Wildcard in Generics

Lower - bounded wildcards in Generics
Upper bounded wildcards in Generics
Using multiple bounds in Generics
The get and put principle of bounded wildcard
Restriction of Wildcards in generics

No comments:

Post a Comment

Chitika