Search code examples
javaeclipsemethodsoverridingjava-6

eclipse override method error on java 6, compiler 1.6


Eclipse is giving an error whenever I try to Override a superclass method. 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 ". I have already set the Compiler Compliance level to 1.6. Help!!


Solution

  • 1) You can't Override private methods.

    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. That is why compiler error.