• 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: 8231
144
  • 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.
 
Try 100 things. 2 will work out, but you will never know in advance which 2. This tiny ad might be one:
ScroogeXHTML 7.1 - RTF to HTML5 / XHTML converter
https://coderanch.com/t/690611/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!