java - 扩展内部接口(interface)?

标签 java inheritance interface implements

我有一个简单的问题:

为什么 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/

相关文章:

java - 转换对象时 event.getItem() 和comboBox.getSelectedItem() 之间有什么区别

java - 获取 WebSphere 应用程序服务器的单元名称

c# - 接口(interface)泛型返回类型

api - 接口(interface)控制文件例子?

java - Java框架: correct to expose implementation directly vs interface?

java - Selenium:更改实例或连接两个实例

java - 即使我使用 NestedScrollView,ToolBar 也无法彻底滚出屏幕

python - 父访问在 Python 中子定义的类变量?

swift - 泛型模式的泛型

java - 如何对这个类进行类型转换?