File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "covariant returns" Watch "covariant returns" New topic

covariant returns

Satish Ray

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.


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

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:
subject: covariant returns
It's not a secret anymore!