Phase 1 Language Basics + Advanced _1-3-Java language senior _02- inheritance and polymorphism _ Section 1 of the same name inherited three kinds of _4_ class district molecular methods


Local variables and member variables also have duplicate names
how to distinguish three kinds of problem variables of the same name as

the new parent

and then a new subclass inherits the parent class


the parent class has 10 equal num

subclasses have 20 equal num

subclass definition is equal to the local variable Num 30

so there should be three num. A parent num. Subclass num. There is a local variable num subclass

super

In a subclass I wanted to visit here and if num parent class is how to access the 10? Here introduce a new keyword super



distinguish three







 

Guess you like

Origin www.cnblogs.com/wangjunwei/p/11210356.html