Should I remove the @Override annotation?

The following code gives an error about public void control() {

.

EClipse provides a hint for removing the @Override annotation. I looked at docs.oracle and found that if a method marked with @Override could not properly override the method in one of its superclasses, the compiler generates an error.

I don't understand what it means "cannot override correctly"?

public class PersistenceFlowController implements controllers.FlowController {
   @Override
   public void control() {
      // Do some works here
   }
}


package controllers;
public interface FlowController {   
   void control();  
}

      

+3


source to share


1 answer


In JDK 1.5 it @Override

can only be applied to methods from the parent class. In JDK 1.6 and up, it can also be used for interface methods. I am assuming you have Eclipse installed to comply with JDK 1.5 compilers. You can check or change this in the Java Compiler tab of the project properties dialog.



+18


source







All Articles