1: Member variables, compile-time: Refer to the class in which the reference variable belongs to has the member variable called, has, compiles through, no, compiles failed.
Run-time: production test whether the referenced variable belongs to a class that has a calling member variable and runs the member variable in the owning class.
(Simple: Compile and run-time reference to the left of the equals sign)
2: Member functions compile-time: Refer to the class in which the referenced variable belongs to have the function called, have, compile through, no, compile failed.
Runtime: Refer to whether the object belongs to a class that has a function called, there, compile through, no, compile failed.
(Simply put: look to the left at compile time, see right at runtime)
3: Static functions, compile time: Refer to the class in which the reference variable belongs has a static method called, there, compile through, no, compile failed.
Runtime: Refer to the class in which the reference variable belongs has a static method called, there, compile through, no, compile failed.
(Simple: Compile and run look to the left) "static method can be called directly with the class name."
1 Importjava.util.ArrayList;2 ImportJava.util.Iterator;3 Importjava.util.List;4 5 Public classTest {6 7 Public Static voidMain (string[] args) {8 //TODO auto-generated Method Stub9A A =NewB ();TenA.dosomething ();//wo shi A OneA.B ();//hi:b ASystem.out.println (A.AA);//8 - - } the - } - - classA { + intAA = 8; - + PublicA () { ASystem.out.println ("A"); at } - - Public Static voiddosomething () { -System.out.println ("Wo shi A"); - } - in Public voidB () { -System.out.println ("Hi:a"); to } + - } the * classBextendsA { $ intAA = 10;Panax Notoginseng - PublicB () { theSystem.out.println ("B"); + } A the Public Static voiddosomething () { +System.out.println ("Wo shi B"); - } $ $ Public voidB () { -System.out.println ("Hi:b"); - } the -}
3 Examples of features
The result is:
A
B
Wo Shi A
Hi:b
8
Summary of characteristics of Java polymorphic members