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:
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
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)
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