Access rights in Java

There are four access permissions in Java, from large to small: public – > protected – > Default (friendly) – > private.

For a brief description:

Public scope is global;

The protected scope is within the class, under the same package and subclass;

Default or friendly, the scope is within the class and under the same package;

The private scope is only internal to the class.

See also the following figure:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>