Originally posted by bill bozeman:
The best way to understand this is to think what happens when you override a method. If you have a Parent class name A and a child class that extends A named B, then you create an instance like this:
A a = new B();
perfectly legal and used all the time. Then when you call a method like a.aMethod();, if it is an overridden method the body from class B() runs because of late-binding. But with a static method, you get don't get the method body of B() but of A() because it is not overriding the method, it is hiding it.
188.8.131.52 Overriding (by Instance Methods)
An instance method m1 declared in a class C overrides another method with the same signature, m2, declared in class A if both
1. C is a subclass of A.
* m2 is non-private and accessible from C, or
* m1 overrides a method m3, m3 distinct from m1, m3 distinct from m2, such that m3 overrides m2.
184.108.40.206 Hiding (by Class Methods)
If a class declares a static method, then the declaration of that method is said to hide any and all methods with the same signature in the superclasses and superinterfaces of the class that would otherwise be accessible to code in the class. A compile-time error occurs if a static method hides an instance method.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koophttps://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton