我有一个简单的问题:
为什么 Eclipse 强烈要求实现这两个接口(interface)?
public abstract class Gateway implements IPlayerity, IItemity {
public interface IPlayerity { ... }
public interface IItemity { ... }
// I...ity
}
我收到此错误消息:
IPlayerity cannot be resolved to a type
最佳答案
鉴于 JLS 的工作方式,您有一个无法解决的循环依赖(尽管我不确定在 JLS 的哪个位置记录了这一点)。
IPlayerity 和 IItemity 接口(interface)对 NestedInterfaces 类 header 定义不可见,因为它们在其中。我可以通过将您的程序更改为
来解决此问题public class NestedInterfaces implements
NestedInterfaces.IPlayerity, NestedInterfaces.IItemity
{
public interface IPlayerity {}
public interface IItemity {}
}
但是 Eclipse 给了我这个错误,这个错误更清楚了:
Multiple markers at this line
- Cycle detected: the type NestedInterfaces cannot extend/implement itself or one of its own member types
- Cycle detected: the type NestedInterfaces cannot extend/implement itself or one of its own member types
关于java - 扩展内部接口(interface)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6711363/