访问修饰符在 JVM 内部如何工作?
最佳答案
Java Virtual Machine Specification详细介绍了这一点。特别是section 2.7.4 Qualified Names and Access Control状态:
A field, method, or constructor of a class may be declared using at most one of the
public
,private
, orprotected
keywords. Apublic
member may be accessed by any class or interface. Aprivate
member may be accessed only from within the class that contains its declaration. A member that is not declaredpublic
,protected
, orprivate
is said to have default access and may be accessed from, and only from, anywhere in the package in which it is declared.
关于java - 访问修饰符在 JVM 内部如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8722599/