问题描述
我在Eclipse中的 @Override
注释中有一个令人讨厌的问题。通常,当我在一台新的电脑上导入工作项目时,Eclipse将某些 @Override
注释标记为错误。如果我删除注释,一切都很好,Eclipse也表示方法覆盖了父方法,但是添加覆盖注释会再次导致错误。我目前正在研究一个Android项目,所以这可能是Android的问题,而不是Eclipse。
I have a annoying problem with @Override
annotations in Eclipse. Often when i import working projects on a new PC, Eclipse marks some of the @Override
annotations as wrong. If i remove the annotations everything is fine and Eclipse also indicates that the methods are overriding the parents methods but adding the Override annotation causes the error again. I am currently working on an Android project so it might be a problem with Android and not with Eclipse..
推荐答案
这是最多的可能是因为您在Java 1.5和Java 1.6之间进行切换。在1.5中,您无法使用@Override标记接口实现,但可以在1.6中。
This is most likely because you are switching between Java 1.5 and Java 1.6. In 1.5 you couldn't mark interface implementations with @Override, but you can in 1.6.
一个快速的Google搜索可以很好地解释这个注释之间的区别两个版本:
A quick Google search turned up this good explanation of the difference in this annotation between the two versions: http://www.techienuggets.com/CommentDetail?tx=38155
事实上,JDK API文档中
覆盖注释的描述未更新
。这是
报告为一个错误:
It is fact that the description of the Override annotation was not updated in the JDK API docs. This has been reported as a bug:
这篇关于在Eclipse中覆盖注释的Bug的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!