• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Please suggest how to inherit static method from class and override one method among that?

 
jacob deiter
Ranch Hand
Posts: 584
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a class(A) with some static methods, I want to inherit all the method of class A and override one Method. Overriding Static method is not possible,

Please suggest how to inherit static method from class and override one method among that?
 
Antany Vasanth
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Jacob,

Please refer the below thread. It will give some idea about static methods and its usage in subclasses.

http://www.coderanch.com/t/456150/Java-General/java/All-about-static-methods

Regards,
Antany
 
Vijitha Kumara
Bartender
Pie
Posts: 3918
10
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jacob deiter wrote:I have a class(A) with some static methods, I want to inherit all the method of class A and override one Method. Overriding Static method is not possible,


Yes, You can't override static to be non static in the subclass (OverridingVsHiding). Of course you can hide the methods by redefining them in the sub class (as static methods). If you expect the runtime polymorphism with those method, well you may have to look other options depending on your requirement.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50196
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
People have already told you it is not possible to override static members. You have some very bad design if you are even thinking of doing that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic