Skip to content

【反射】Java 不同包的类如何通过反射获取缺省(default)修饰的类的成员变量 #2

Description

@0xbitboy
package a;
class A{
  // 只有在包a下的类才能访问变量a;
  public static final String a = 'a';
}

package b;
public class B{
    public static void main(String[] args) {
        //此处因为类的访问限制,是无法获取到A类的。
         A.a;
    }
}


Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions