http://teddyboy200382.blog.163.com/blog/static/320112002008825112549780/
Description of these four keywords before I want to justClassTo make a simple definition of the relationship, for the inheritance of their ownClass,Base classcan be thought of as their own children, and for a directory of their ownClasses, thinking they are all their friends.
1,Public:public indicates that the data member, member function is open to all users, and all users can call
< Span lang= "en-US" >2, private : private means private, private means except class No one else can use it directly, and private property is inviolable, even for children and friends.
3, protected: protected , free to use without any restrictions, and for other external classprotected private
4,friendly: do not write when the default is friendly,friendly is friendly, for friends, Can be used freely, without any restrictions, and for other external classes, even children, can not be used .
Scope Current class same package descendant class other package
Public√√√√
Protected√√√x
friendly √ √ x x
private √ x x x
[Java]private, public,protected,friendly difference (reprint) Remember all at once