Static:
At compile time the allocated memory will always exist (not recycled) until the program exits will release this memory space, prior to instantiate this method already exists in memory, with the object class does not matter. If a child class static methods of the same name is defined, and will not be rewritten, but should be a static method in the subclass to another memory allocation, and does not override that said, simply repeat the name.
Parent code
. 1 public class Fu { 2 public static void Show () { . 3 System.out.println ( "static methods of the parent class" ); . 4 } . 5 public void Method () { . 6 System.out.println general ( "parent class method " ); 7 } 8 }
Subclass code
public class Zi the extends Fu { public static void main (String [] args) { Fu FU = new new Zi (); fu.show (); fu.method (); } public static void Show () { System.out.println ( "static subclass" ); } public void method () { System.out.println ( "general procedure subclass" ); } }
The output is:
Static methods of the parent class
General Procedure subclass
When the parent class reference point to a subclass object will call the static method of the parent class, this behavior does not have the polymorphism! Only that a subclass can inherit the parent class's static methods! Static method has nothing to do with the object!