Public, Private, Protected, and default identifiers

Private methods/properties (priviate int a;) can’t be accessed from outside of the class.
Protected (protected int a;)can be accessed in the class or from its sub-class.
Public (public int a;)can be accessed from any places.
The methods/properties without any identifier (int a) can be access by the classes within the same package; but can’t be accessed out of the package.

In a class, all identifiers can access each other. So in fact “identifier” is for “external” access.

posted @ 2011-12-01 21:33  allenbackpacker  阅读(144)  评论(0编辑  收藏  举报