Java main class M can directly access its own private members, even if the new one in main itself, is only a local variable in its own static method, the local variable can still access its own private members, as long as the local variable body in its own class M.
The other Class A is defined outside the main class M, and the following statement is written in the main method of the Master class:
1, M m = new M, the main class private member can be accessed directly by M.P because the statement is in the M class body
2, a A = new A, the private member cannot be accessed directly through A.P, because the statement is in the M class body and is not in the class A body
The inertia of learning C + + in college is that private members can never be accessed directly by new variables, must be encapsulated in the class body with public get ()/set (), and then new variables can only be accessed through get ()/set (). What was not accepted and understood at the time was that the main method was in some kind of body and could also own new. Now it's finally understood.
About access to Java Private member variables