Class members -static

Class Members

For the static keyword, there is a very important rule: class members (including static methods, static initialization block, static inner classes and static enumerated classes) can not access instance members (including fields, methods, initialization block, inner classes , and enumerated classes)

Class members belong to a class, instance members belonging to the object;

Scope class members more than members of the scope instance , class members have fully initialized, the instance members are not initialized situation may arise, in which case if a class member to access instance members will lead NullPointException exception or other error.

Guess you like

Origin www.cnblogs.com/woshi123/p/12457418.html