Private variables are not accessible in subclasses. Thats what the access modifier protected
is for. What happened here is that when you access a variable that doesn't exist, it creates one for you with the default access modifier of public
.
Here is the UML to show you the state:
Please note: the subclass still has access to all the public
and protected
methods and variables from its superclass - but are not in the UML diagram!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…