@Override must override a superclass method problem solving

@Override was introduced by JDK5 and is described as follows:
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.
The description in the JDK6 documentation is exactly the same! But the real trouble lies in the understanding of superclass  ! JDK5 believes that Override overload is to override the method of the parent class, while JDK6 defines both the method of overriding the parent class and the method of implementing the interface as Override superclass. Therefore, as long as @Override is written in the place where the interface method is implemented, JDK5 will report an error

 

I personally feel that @Override of JDK5 may be a design bug:) Because I feel that the understanding of JDK6 is relatively correct.

 

Third, the method to modify the error caused by @override in the Myeclipse environment

 

Right-click the project ->build path->configure build path->java Compiler (in the row on the left) ->Compiler compliance level on the right is modified to 1.6

 

Similar Posts: