One.
Start by writing a special point program to learn about the inner class knowledge points.
(In the absence of explanation, first comb yourself, outer this external class function to access the inner class, you must also create an inner class object)
The result of compiling the run, I guess is 5. The DOS results show that we guessed there was nothing wrong.
If we want to output the NUM is 4, how to modify it. My idea is to change the method body to new Outer (). Num. But the method used in the video is different from mine, and the show method in the called Inner class has been modified to become the output this.num, which is num in the object, not num in the method body.
Next is the printing num=3 case, the output statement to Outer.this.num, in fact, before the output num=4, but also can be written Inner.this.num, but inner more redundant, do not write.
Here is a question about the number of points (.) In the knowledge point of the class and object. What are the rules of the Operation ? Is there a clear statement?
There is no such thing as a series of NUM when actually developing.
Why does an inner class have direct access to members in an external class? The representation is that NUM is placed in the inner class, but it is called num in the outer class. Just like method (), where the method body is written with show (), why write the Show () method from the method () and have direct access to other members? That's because this is omitted here, which is actually this.num.
The call is for a reason, not for granted.
This is the object of the outer class.
Java-Preliminary Understanding-tenth-inner class-Details