1) Class visibility: public; friendly (no keyword); protected; private; public: public class, visible inside and outside the package, with the highest visibility level; friendly: it is also the default security level, which is invisible outside the package and visible inside the package. it is used at the same level as the protected level. protected: protection level, which can only be used for internal classes. visible to classes and subclasses (inside the package subclass, outside the package subclass is invisible) and other classes in the package. private: private level. It can only be used for internal classes and is only visible to the class itself. The visibility of the class is still complicated, especially after the internal class is nested, but the basic rules are described above. Therefore, it is recommended that if the class is nested, it should be no more than two layers, that is, only one layer is nested. This process is relatively simple, and there is no need for multiple visibility nesting to complicate things. The following is the sample code: [java] public class MyClass02 {// protection-level visible to subclasses and friendly classes in the same package protected class MyClass03 {} // The classes below are only visible to this class, cannot be accessed outside the class. private class MyClass04 {}// same as protected. class MyClass05 {}// visible to the subclass, inside the package, and other classes outside the package. public class MyClass06 {}} class MyClass021 extends MyClass02 {export theA = new MyClass03 (); MyClass05 the05 = new MyClass05 ();} class MyClass11 {MyClass03 theA = new MyClass02 (). new MyClass03 ();} publi C class MyClass02 {// the protection level is visible to the subclass and friendly class in the same package. The classes under protected class MyClass03 {} // are only visible to this class and cannot be accessed outside the class. private class MyClass04 {}// same as protected. class MyClass05 {}// visible to the subclass, inside the package, and other classes outside the package. public class MyClass06 {}} class MyClass021 extends MyClass02 {export theA = new MyClass03 (); MyClass05 the05 = new MyClass05 ();} class MyClass11 {MyClass03 theA = new MyClass02 (). new MyClass03 ();} [java] // located in another package. this class inherits from MyClass02 class MyClass 022 extends MyClass02 {public void Do () {// MyClass03, MyClass05 invisible, the following statement compilation error. // MyClass03 theA = new MyClass03 (); // MyClass05 the05 = new MyClass05 (); // The following statement is acceptable. myClass06 the6 = new MyClass06 () ;}// located in another package. this class inherits from MyClass02class MyClass022 extends MyClass02 {public void Do () {// MyClass03, MyClass05 invisible, the following statement compilation error. // MyClass03 theA = new MyClass03 (); // MyClass05 the05 = new MyClass05 (); // The following statement is acceptable. myClass06 the6 = new MyClass06 () ;}} 2) class member visibility: public members, other classes visible (inside the package and outside the package), and classes outside the package are visible; visibility of internal Nested classes; protected: Protection Level, visible to other classes in the package, visible to sub-classes inside and outside the package; visible to internal Nested classes; no keywords: friendly, visible to other classes in the package, but the subclass inside and outside the package is invisible; the nested classes are visible; there is no inheritance. Private: private. Other classes cannot be accessed, but they are visible to internal classes of the class. In addition, internal classes can be defined in class methods, the visibility at this time is closely related to the scope. it is generally not recommended to use classes like this, which will increase the difficulty of maintenance and understanding.