File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

static / non-static method overriding

 
Ryan Deiter
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7292
Netbeans IDE VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic