1. Meaning polymorphic
A reference point to the parent class subclass object
format:
The parent class name of the object name = new subclass name
Interface name object name = new implementation class name
2. Access member variable in two ways:
1. Direct access via the object name of the member variable: Look Who left of the equal sign is a priority with anyone, not then look up.
2. Indirect access by members of the member variables method: see the method belongs to whom, with priority who is not looking up.
3. The benefits of polymorphism
1. make the code simple, flexible, no matter how the right new, how they change, are fixed to the left
4. Transformation ---- up downcast
Rotated upward writing is polymorphic, the upward turn, the unique subclass method can not be used, it is drawn downward turn
Reduction is turned downwards: format object name = name subclass (subclass name) parent class object
5. The the instanceof keyword, using basic (IF) downward transition with, judgment, if not determined, may occur class cast exception
Format: instanceof Object returns a boolean value class name Results