covariance : Java Glossary

*0-9ABCDEFGHIJKLMNOPQRSTUVWXYZ (all)

covariance
Java did not originally make the same distinctions that other languages refer to as covariance. With covariance, you can override a method that returns a Dog object with one that returns a Dalmatian object. However, starting with Java 1.5, you can. The returned type must be a subclass of the return type of the method overridden. Most commonly this is used by a clone implementation to return the specific class rather than a generic Object.

Covariance is implemented with two byte code methods per Java method, one hidden bridge that returns the base type and another conventional method that returns the subtype. The base bridge method invokes the subtype method.


This page is posted
on the web at:

http://mindprod.com/jgloss/covariance.html

Optional Replicator mirror
of mindprod.com
on local hard disk J:

J:\mindprod\jgloss\covariance.html
Canadian Mind Products
Please the feedback from other visitors, or your own feedback about the site.
Contact Roedy. Please feel free to link to this page without explicit permission.

IP:[65.110.21.43]
Your face IP:[3.137.220.120]
You are visitor number