我有以下两个类(在两个单独的文件中).
public class Foo
{
public static class A
{
public static final boolean FLAG = false;
}
public final A A = new A();
}
public class Bar
{
void method()
{
if (Foo.A.FLAG) <<<< this is giving "Cannot make static ref to non-static field
// do something
;
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,为什么编译器不能记录通过Foo.A,我的意思是类A,而不是成员,这也恰好被命名A?
| 归档时间: |
|
| 查看次数: |
704 次 |
| 最近记录: |