• Post Reply Bookmark Topic Watch Topic
  • New Topic

Covariant  RSS feed

 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, In this Covariant example, At Line # 12, Are we getting Line#7 return type "Integer" (or) Line#8 return type "int" ("i" is of int type) ?
 
Saloon Keeper
Posts: 8994
168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The return type of the method is Integer, so that is what is returned. In this case, i is autoboxed. The main method expects an Integer and that's what it's getting.
 
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this code. It prints the class of the returned object.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!