JasonLaw
2023-04-25 22:33:05 +08:00
这种问题问 ChatGPT 最好了。
In Java, the protected keyword is a visibility modifier that can be applied to class members (fields, methods, and nested classes) to restrict their access to the class itself, its subclasses, and other classes in the same package.
More specifically, when a class member is declared as protected, it can be accessed by:
The class itself
Any subclass of the class, even if the subclass is in a different package
Any other class in the same package as the class