Thanks for the link, that helped me too. But now I have another question: What's the point of hiding(redefining?) a static method if there is no polymorphism involved, and if one can always access the original static method through a class, its instance, or an instance of its subclass?
"Rustam BT " welcome to Javaranch
please check your private messages for an important administrative matter. You can check them by clicking the My Private Messages link above.
The same FAQ wrote:With classMethod() though. since (ahem) it's a class method, the compiler and JVM don't expect to need an actual instance to invoke the method. And even if you provide one (which we did: the instance referred to by f) the JVM will never look at it. The compiler will only look at the declared type of the reference, and use that declared type to determine, at compile time, which method to call. Since f is declared as type Foo, the compiler looks at f.classMethod() and decides it means Foo.classMethod. It doesn't matter that the instance reffered to by f is actually a Bar - for static methods, the compiler only uses the declared type of the reference. That's what we mean when we say a static method does not have run-time polymorphism.
That is the reason why "overriding" a static method actually "hides" it.
Thanks for the warm welcome , it's good to be here.
I think now I understand how and why an "overridden" class method actually becomes "hidden", thanks to you and the study guide. My only problem is that I can't think of any single case where one would want to "hide" a static method (for a good design, effectiveness, reuse or any other reason). It actually seems redundant to me.