Today, when copying the eclipse project to another computer, there are always @override errors. The prompt is to remove @override. However, there are many annotations in the project. Java Xiaobai thinks that even if I don’t know the difference between the existence and non existence of this preparation, it must be useful since it exists, In addition, @override exists in many places in the project, so you can’t remove it all. I checked it and summarized it
Error reason:
At first, I thought it was a jar package reference problem. I tried to change the jar package, but it was useless. Only then did I know it was a JDK problem. @ override already existed when it was jdk5, but it did not support the implementation of the interface. I thought it was not an override and reported an error. JDK6 has corrected this bug, and @ override can be added to both the method override of the parent class and the implementation of the interface. To solve this problem, first make sure that JDK 1.6 is installed on the machine (in fact, I’m not sure about this problem here, because I only have version 1.8 on my computer, but there is no 1.8 in the selection, so I chose 1.6 according to the tutorial)
First, method 1: (I tried it in my project, but it’s useless)
Select the eclipse menu windows – > Preferences–> java-> Compiler–> Compiler compliance level select 1.6, refresh the project and recompile
Method 2: (problem solving)
Right click on the error reporting project and select properties — > Java Compiler–> Select 1.6 from compiler compliance level, refresh the project and recompile
Extension: Java Override @ override annotation in A little understanding of writing and not writing
Generally speaking, there is no difference between writing and not writing, and the JVM can recognize itself
In the case of writing: that is to say, the subclass must override the method of the base class, and the base class must have a method
(The control type (public, protected, return value, parameter list type) is consistent with the method completed by the subclass method, otherwise an error will be reported (the overridden method cannot be found).
When the @override annotation is not written, when the base class exists and all conditions of the subclass meet, the method is to implement the override; If the conditions are not met, it is used as a newly defined method.
Therefore, if you want to override the base class method, you’d better write the @ override annotation, which is helpful for the compiler to help check for errors
Similar Posts:
- JAVA: How to Solve @override error
- @Override must override a superclass method problem solving
- Steps of MyEclipse / eclipse importing sun.misc.base64encoder jar package
- Sun.misc.base64decoder import exception and handling ideas
- [Solved] Eclipse Error: Access restriction: The type ‘BASE64Decoder’ is not API
- The solution of base64decoder prompt error under eclipse
- The solution of the import javax.servlet cannot be resolved in Java
- Eclipse Unable to install breakpoint in XXX [How to Solve]
- Type safety: unchecked cast from object to
- Invalid project name: Project “XXX” already exists