zoukankan      html  css  js  c++  java
  • @Override must override a superclass method 问题解决

    一、问题的由来

    最近接手了了一个合作企业的项目,前期不是我司开发的,上周做了几天的技术对接,客户端界面由我负责对接,从svn检出之后,迫不及待的导入到了本地的myeclipse中,谁知立马就出现了那个小红叉,各种找原因,最终得以解决,现将研究过程总结如下:

    二、@Override 是JDK5引入的,描述如下: 
    Indicates that a method declaration is intended to override a method declaration in a superclass. If a method is annotated with this annotation type but does not override a superclass method, compilers are required to generate an error message. 
     

    在JDK6文档中的描述是一模一样!但是真正的麻烦就出在superclass 的理解上!JDK5认为Override重载是覆盖父类方法,而JDK6则将覆盖父类方法与实现接口方法,都定义为Override superclass。 因此只要是实现接口方法的地方写了@Override,JDK5都会报错

    个人感觉JDK5的@Override可能是设计时候的bug吧:) 因为感觉JDK6的理解比较正确。

    三、Myeclipse环境下修改@override引发的错误的方法

     

    项目右键->build path->configure build path->java Compiler(左边那排中) ->在右边的Compiler compliance level 修改版本为1.6
  • 相关阅读:
    一个类GraphQL的ORM数据访问框架发布
    关于 IIS Express 常用设置
    代码失控与状态机(上)
    实体类的动态生成(三)
    实体类的动态生成(二)
    搭建 github.io 博客站点
    实体类的动态生成(一)
    JDK的下载和安装
    三步搞定jupyter nootebook 主题切换
    LeetCode刷题--存在重复元素
  • 原文地址:https://www.cnblogs.com/geekdc/p/5333652.html
Copyright © 2011-2022 走看看