The difference between private, protected, public and default in Java 1. The public
modifier has the greatest access rights and can access any class, interface, exception, etc. under the CLASSPATH.
2. protected modifier, its main role is to protect subclasses. (The external package is not accessible, but it is possible for the external package to inherit its subclasses)
3. For default, it also becomes friendly (friends) when it is a little bit, it is designed for the access of this package. (External packages are not accessible, and it is not possible for external packages to inherit its subclasses)
4.private modifier, its access rights are limited to the interior of the class, which is a manifestation of encapsulation.
Reference text:
https://my.oschina.net/u/1169535/blog/403589
The difference between private, protected, public and default in Java
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=326975448&siteId=291194637
Recommended
Ranking