@Override编译错误,实现一个接口(eclipse jdk1.6.0_23 linux) [英] @Override compile error, implementing an interface (eclipse jdk1.6.0_23 linux)

查看:155
本文介绍了@Override编译错误,实现一个接口(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屋!

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