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

查看:27
本文介绍了覆盖注解和 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);
   }
//...
}

AccountICAccount

但是编译失败.

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  

有什么问题?

推荐答案

Override 注释仅在从 Java 1.5 中覆盖类中的方法时使用.它也适用于 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天全站免登陆