Ken Kafieh wrote:
> When you override a non-static method, a call to that method from the
> super-class properly results in the sub-class version of that method being
> called. BUT, when you override a static method, it appears --to my
> frustration-- that a call to that method from the super-class results in the
> super-class version of the method being called!
That's sort of correct. Really, the better way to use terminology is to
say that you can't override a static method. Static methods are subject
to something called "hiding", in which a method of the same name and
signature in a subclass doesn't replace a method from the superclass,
but instead coexists with it such that some method calls resolve
(lexically, at compile-time) to the subclass implementation instead of
the superclass.
This makes a lot of sense, when you think about it. The entire point of
a static method is that it is called without specifying any particular
instance of the class. As such, it makes no sense to resolve the method
using an instance of the class.
Since you haven't given a working example of the code that doesn't work
(the code you provided had an empty main method, which means it prints
nothing at all), I can't give more specific advice. Please post a
complete example and I'll help you out a little more.
--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation