覆盖注释和JDK 1.5 [英] Override annotation and JDK 1.5

查看:73
本文介绍了覆盖注释和JDK 1.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JDK 1.5,这是我的课程:

I'm using JDK 1.5, here is my class:

public final class Account implements ICAccount

{
//...
   @Override
   public ObjectID getId()
   {
      return new ObjectID(id);
   }
//...
}

Account覆盖了ICAccount

但是编译失败.

Account.java  method does not override a method from its superclass  

如果我使用的是JDK 1.6,则编译成功.

If i'm using JDK 1.6 the compilation succeeds.

在@Override注释的文档中,我看到

In documentation to @Override annotation I see

Since:
1.5  

出什么问题了?

推荐答案

仅当从Java 1.5中的类重写方法时,才使用Override注释.它还适用于从Java 1.6实现接口方法.

The Override annotation is only used when overriding methods from classes in java 1.5. It also works for implementation of interface methods from Java 1.6.

这篇关于覆盖注释和JDK 1.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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