Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is covariant type

 
Nancy Antony
Ranch Hand
Posts: 145
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Ranchers,

K&B pg 111 says,"In Overriding return type can’t change except for
covariant returns."

What does it mean exactly?

Regards,
Nancy
 
Ankit Garg
Sheriff
Posts: 9528
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you do a simple google search??
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
 
Ankitt Gupta
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Covariant type means your return type of the overriding method should be subclass of the return type of overridden method.

 
Ankit Garg
Sheriff
Posts: 9528
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deepak Bala wrote:Here is a more fancy URL

http://lmgtfy.com/?q=what+is+a+covariant+return


 
Stephen Davies
Ranch Hand
Posts: 352
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankitt Gupta wrote:Covariant type means your return type of the overriding method should be subclass of the return type of overridden method


I would say Ankitt it may be a subclass be not that it should be.
 
Ruben Soto
Ranch Hand
Posts: 1032
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or it could be an implementing class, or an extending interface, if the return type of the overridden method is an interface. The key is that the covariant return must pass the Is-A test for the return type of the overridden method.
 
Nancy Antony
Ranch Hand
Posts: 145
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ranchers
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic