Java Basics: object-oriented inner class ---

Java language allows classes defined in class again, in such a class called inner classes within a class other. Inner classes are divided into: conventional inner classes, local inner classes, anonymous inner classes and static inner classes four.

Static inner classes

If you are using a modified static inner class, then this internal class belongs outside the class itself , rather than an object outside the class. Therefore, the use of modified static inner classes are called inner classes classes, in some places, also known as static inner classes.

Static inner class can contain static members, may also contain non-static member. According to the rules of static members can not access non-static members, static inner classes can not access instance members of the outer class, class members can only be accessed outside the class. Even the static internal examples of class methods can not access instance members of the outer class, outside of class can only access static members following code illustrates this rule:

Published 81 original articles · won praise 37 · views 50000 +

Guess you like

Origin blog.csdn.net/gaolh89/article/details/100129433