*
The moose likes Java in General and the fly likes covariant returns Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "covariant returns" Watch "covariant returns" New topic
Author

covariant returns

Satish Ray
Greenhorn

Joined: Jul 13, 2006
Posts: 16
Can anybody explain me what exactly are covariant returns?
Petrus Pelser
Ranch Hand

Joined: Feb 20, 2006
Posts: 132
Covariant returns are when you return a subtype of the return type defined by the method you are overridding.

E.g


This is a legal override as the overridden method returns a subtype of the original method's return type.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Note also that covariant returns are legal in JDK 5 and later, but not in earlier versions.


"I'm not back." - Bill Harding, Twister
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: covariant returns
 
Similar Threads
covariant returns
Covariant Returns
query related overriding.
including covariant return ?
Need help for method selection