@Override编译错误,实现一个接口(eclipse jdk1.6.0_23 linux) [英] @Override compile error, implementing an interface (eclipse jdk1.6.0_23 linux)
问题描述
对于正在实现接口的类使用@Override注释时,我在eclipse中收到编译错误。
编译器合规级别设置为Java 6.0。 / p>
我使用的是最新版本的6.0 jdk。
错误:
类型{classname}的methodname必须重写超类方法
同样的代码在具有可比配置的mac上可以正常工作。
public interface ChannelIF {
...
public boolean canSendNarrowcast();
public boolean canSendBroadcast();
}
public class FacebookChannel implements ChannelIF
{
...
@Override
public boolean canSendNarrowcast(){return true; }
@Override
public boolean canSendBroadcast(){return true; }
}
此功能在Java 6和更高版本。我看到你 使用jdk 1.6。那很好。可能的原因:您正在使用 -source 1.5
进行编译。是这样的情况吗?如果是,可以将其更改为 -source 1.6
?
I am getting compile errors in eclipse when using the @Override annotation for a class that is implementing an interface.
Compiler compliance level is set to Java 6.0.
I am using the latest version of the 6.0 jdk.
Error: "The method {methodname} of type {classname} must override a superclass method"
Same code works fine on mac with comparable configuration.
public interface ChannelIF {
...
public boolean canSendNarrowcast();
public boolean canSendBroadcast();
}
public class FacebookChannel implements ChannelIF
{
...
@Override
public boolean canSendNarrowcast() { return true; }
@Override
public boolean canSendBroadcast() { return true; }
}
This feature is only valid in Java 6 and higher. I see you are using jdk 1.6. That's good. Possible cause: You are compiling with -source 1.5
. Is this the case? If so, can you change it to -source 1.6
?
这篇关于@Override编译错误,实现一个接口(eclipse jdk1.6.0_23 linux)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!