This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • 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
Saloon Keeper
Posts: 3997
42
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
Saloon Keeper
Posts: 3997
42
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Delete me please]
 
Ankit Garg
Sheriff
Posts: 9610
37
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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!