• Public, protected,default, private(Java access control, only these four guys)
  • Java external classes can only be decorated by public and default (but why?).
  1. It is obviously meaningless to define an external class as private. If a class is defined, other classes cannot communicate with it, and it is meaningless to exist independently.

  2. The default is default, which means that by default the permission modifier in front of the external class is default which is the package permission

  3. protected Is increased on the basis of defaul subclasses can also access permissions, that is to say, even if you out of the same package, or in another bag you want to access this class, you have to is a subclass of his, this method used to modify good passing, good, that we try the external class, building a class in another bag to succeed him, cannot find dad, please, how to inherit (Which came first, chicken or egg), then let him back to the same package access, yes, can find the parent, can complete inheritance, but think, for an external class, it does not have the same thread as default. And it can jump out of the same package access meaning does not exist, and what is the difference between default can do things why you protected. Java does not need salted fish

  4. Public allows classes in other packages to access this not salty fish

conclusion

In fact, to sum up, the access between the external class and the external class is only inside the package, so it is natural that only public and default can be modified, the other two are multi-fish