@Override 编译错误,实现一个接口(eclipse jdk1.6.0_23 linux) [英] @Override compile error, implementing an interface (eclipse jdk1.6.0_23 linux)
问题描述
在 Eclipse 中对实现接口的类使用 @Override 注释时出现编译错误.
I am getting compile errors in eclipse when using the @Override annotation for a class that is implementing an interface.
编译器合规性级别设置为 Java 6.0.
Compiler compliance level is set to Java 6.0.
我使用的是最新版本的 6.0 jdk.
I am using the latest version of the 6.0 jdk.
错误:{classname} 类型的方法 {methodname} 必须覆盖超类方法"
Error: "The method {methodname} of type {classname} must override a superclass method"
相同的代码在具有类似配置的 mac 上运行良好.
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; }
}
推荐答案
此功能仅在 Java 6 及更高版本中有效.我看到你正在使用 jdk 1.6.那挺好的.可能的原因:您正在使用 -source 1.5
进行编译.是这种情况吗?如果是这样,你能不能把它改成-source 1.6
?
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屋!