扩展内部接口? [英] Extending an inner interface?

查看:148
本文介绍了扩展内部接口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的问题:

为什么Eclipse会对实现这两个接口感到尖叫?

Why does Eclipse scream about implementing these two interfaces?

public abstract class Gateway implements IPlayerity, IItemity {
    public interface IPlayerity { ... }
    public interface IItemity { ... }
    // I...ity
}

我收到此错误消息:


IPlayerity无法解析为类型

IPlayerity cannot be resolved to a type


推荐答案

你有一个循环依赖,无法解决JLS的工作方式(虽然我不确定JLS在哪里记录)。

You have a cyclic dependency that can't be resolved given the way the JLS works (although I'm not sure where in the JLS this is documented).

接口IPlayerity和IItemity对NestedInterfaces类头定义不可见,因为它们位于其中。我可以通过将程序更改为

The interfaces IPlayerity and IItemity are not visible to the NestedInterfaces class header definition, since they are inside it. I can fix this by changing your program to

public class NestedInterfaces implements 
      NestedInterfaces.IPlayerity, NestedInterfaces.IItemity 
{
    public interface IPlayerity {}
    public interface IItemity {}
}

然后Eclipse给了我这个错误,这更加明确:

but then Eclipse gives me this error, which is much more clear:

 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

这篇关于扩展内部接口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆