您的成员界面是私有的.继承的静态字段不是私有的.
私有成员接口不能用作封闭的顶级类或枚举之外的类型.这对于防止外部代码实现您可能希望更改的接口很有用.从JLS:
The access modifiers protected and private pertain only to member interfaces within a directly enclosing class or enum declaration (§8.5.1).
接口字段是公共的,并由实现该接口的类继承.从JLS:
A class inherits from its direct superclass and direct superinterfaces all the non-private fields of the superclass and superinterfaces that are both accessible to code in the class and not hidden by a declaration in the class.
如果要使该字段仅在实现成员接口的类中可访问,则可以将其声明放在封闭的顶级范围中.
class TestingInterfaceClass {
private static final int i = 0;
private interface InnerInterface {
// ...
}
class inner implements InnerInterface {
// ...
}
}