File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Static methods - overriding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Static methods - overriding" Watch "Static methods - overriding" New topic
Author

Static methods - overriding

Arnb Sen
Ranch Hand

Joined: Feb 23, 2004
Posts: 145
Can static methods be overriden ?


Regards,<br />Arnab
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

No, but they can be hidden. Compile and run this...


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
See also here.


"I'm not back." - Bill Harding, Twister
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
By the way, I take *wanting to override a method that is static* to be
a sign that the method might be better recast as a non-static method.


There is no emoticon for what I am feeling!
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Jeff Albrechtsen:
By the way, I take *wanting to override a method that is static* to be
a sign that the method might be better recast as a non-static method.

Absolutely.

On the other hand, if this is an academic question, I would just add that you can prevent the "hiding" behavior by making the static method final.
Arnb Sen
Ranch Hand

Joined: Feb 23, 2004
Posts: 145
Thank you all for the answers. That was very informative.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Static methods - overriding