• Post Reply Bookmark Topic Watch Topic
  • New Topic

is primitive type accepted for Object class reference return type  RSS feed

 
sakthi vandhana
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

My understanding is every class in java is a subclass of "Object" class. But, in the following code, int is accepted. I thought wrapper class of int is a subclass of Object and not int.
Please clear this.



output
-------

5

Note: I am preparing for OCJP. So just reading topic on "Legal return type" in chapter 2 kathy sierra book
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sakthi vandhana wrote:Note: I am preparing for OCJP. So just reading topic on "Legal return type" in chapter 2 kathy sierra book

I forget the order of that book, but I'm surprised they'd be giving you an example like that without telling you about autoboxing (and unboxing).

Please reply if you don't see how that is involved as well.

Winston
 
sakthi vandhana
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Winston

It was bugging me a lot..
That book did not say about autoboxing upto what i learnt.. I searched the remaining book for autoboxing topic and got it..

Thanks
Sakthi
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sakthi vandhana wrote:Thank you Winston

You're most welcome. Glad you found it.

Winston
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!