Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • 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: 580
  • 0
  • 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
  • 0
  • 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
Posts: 3908
9
Chrome Fedora Hibernate
  • 0
  • 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: 47216
52
  • 0
  • 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.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic