简体   繁体   English

Java 6,编译器1.6上的Eclipse重写方法错误

[英]eclipse override method error on java 6, compiler 1.6

Eclipse is giving an error whenever I try to Override a superclass method. 每当我尝试覆盖超类方法时,Eclipse都会给出错误。 Even simple codes are giving errors. 即使是简单的代码也会出错。 This is the class First 这是班上第一

public class First{
private void Meth(){
}  
}

This is another class extending first 这是另一类首先扩展

public class Second extends First{
@Override
public void meth(){
}
}   

And eclipse gives error "The method meth() of type Second must override or implement a supertype method" "1 quick fix available - Remove '@Override' annotation ". 并且eclipse给出错误“类型为Second的方法meth()必须重写或实现超类型方法”“ 1个快速修复可用-删除'@Override'注释”。 I have already set the Compiler Compliance level to 1.6. 我已经将“编译器符合性”级别设置为1.6。 Help!! 救命!!

1) You can't Override private methods. 1)您不能Override private方法。

2) As soon as eclipse/compiler see @Override statement, it tries to look for relevant protected (or) public method in super class, which is not there. 2)一旦eclipse / compiler看到@Override语句,它就会尝试在超级类中查找相关的protected (or) public方法,而该方法并不存在。 That is why compiler error. 这就是为什么编译器错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM