• Post Reply Bookmark Topic Watch Topic
  • New Topic

Overriding Doubt  RSS feed

 
Abhi vijay
Ranch Hand
Posts: 509
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We cannot override non-static methods with static methods.

All the Wrapper classes extends the Number class, which in turn extends the Object class.
In the Object Class, toString() is non-static, but in the Wrapper Classes, toString() is static. How does that work?
 
Vijitha Kumara
Bartender
Posts: 3973
24
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abhi vijay wrote:

In the Object Class, toString() is non-static, but in the Wrapper Classes, toString() is static. How does that work?


Which Wrapper classes are you talking about? Integer,Double.... ? If so you will have to refer to API for details of those. Because they do have toString() method overriden, plus static toString() (toString(double d) for Double etc...).
 
Vijitha Kumara
Bartender
Posts: 3973
24
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Delete me please]
 
Ankit Garg
Sheriff
Posts: 9608
36
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well the static toString method in the wrapper classes takes a primitive parameter while the non-static toString method of Object class doesn't take any paremeter...
 
Abhi vijay
Ranch Hand
Posts: 509
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh yes! :-(
Sorry for asking such a stupid question.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!