Inner class in JAVA-static inner class

A static inner class is an inner class modified by static. The characteristics of this inner class are:

1, static inner classes can not directly access non-static members of the outer class, but you can () Members of the new outer class way of access

2. If the static member of the outer class has the same name as the member of the inner class, you can access the static member of the outer class through "Class name. Static member"; if the static member of the outer class is different from the member name of the inner class, you can pass "Member name" directly calls the static members of the external class

3, the static objects are created within the class, the class object does not need external, can be created directly inside the class object internal category name = new ();

 

 


operation result:

Access b:1 in the outer class

Access b:2 in inner class

Guess you like

Origin blog.csdn.net/liushulin183/article/details/46672821