Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Covariant returns

 
Sathya Shanmugam
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,

Could any give more examples for covariant returns, Any link would be appreciated..


thanks
 
Sathya Shanmugam
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And also like to have some explanation with example for the following statement from KB book

" Overriding methods can do so only within the bounds of covariant returns"...
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sathya,

" Overriding methods can do so only within the bounds of covariant returns"...




New Thing to learn: You may have heard of bridge method; How does JVM handle to call the overridden method with covariant return type; The compiler automatically inserts the following in the subclass(in out example)

Animal meth() {
return this.meth();
}


Hope you got the concept!

Thanks & Regards,
cmbhatt
 
Sathya Shanmugam
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks chan for your immediate reply

I don't know what is a bridge method :roll:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic