File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes static / non-static method overriding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "static / non-static method overriding" Watch "static / non-static method overriding" New topic
Author

static / non-static method overriding

Ryan Deiter
Greenhorn

Joined: Mar 13, 2002
Posts: 9
i know you can't override static methods by why can't you override a non-static method with a static method.
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

"detox33" --
Please review JavaRanch's naming policy and change your screen name accordingly.
When a method is made static, it becomes a property of its enclosing class, rather than a member of the objects instanced from it. This makes it possible to use the method without creating any object at all.
Method overriding favors a different principle. If you have a method in class Parent overridden in class Child, the idea is you could have either a Parent or Child object in memory, referred to by a Parent reference, and still get the correct behavior (i.e., either the original or overridden method code).
Trying to override a method by using a static modifier implies that you want to supress this dynamic binding itself, as well as the behavior of the original method; this isn't allowed.
Now c'mon, Valentin, break out that JLS and give us the Gospel on the subject.


Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: static / non-static method overriding
 
Similar Threads
static method can be inherited?
Doubt on Abstract class/method <help please>
Instance method?
Confusion in extending Thread Class
Overriding static methods.