Generics, Covariance and Contravariance
←Older revision | Revision as of 07:53, 25 June 2014 | ||
Line 52: | Line 52: | ||
== Generics, Covariance and Contravariance == | == Generics, Covariance and Contravariance == | ||
- | It is well known that while [[Covariance]] and [[Contravariance]] work OK from the source compatibility point of view in [[Java]], | + | It is well known that while [[Covariance]] and [[Contravariance]] work OK from the source compatibility point of view in [[Java]], they are not very [[BackwardCompatible]] from the binary point of view. As the binary compatibility is one of the most important ones for a compiled language like [[Java]], one could think, that usage of [[Covariance]] or [[Contravariance]] is impossible. However it is not (at least not completely) - with the help of [[wikipedia:Type_erasure|erasure]] of generic type information in [[Java]] one can use both-variances to own benefits. |
Imagine there is a simple method that operates on set of integers: | Imagine there is a simple method that operates on set of integers: |