After the project into Eclipse, "it must override the superclass method" error

本文翻译自:'Must Override a Superclass Method' Errors after importing a project into Eclipse

Anytime the I have have to Re-Import My the Projects INTO the Eclipse (IF the I reinstalled the Eclipse, or changed at The LOCATION of at The the Projects), Almost All of My Overridden Methods are not formatted correctly &, Causing at The error: Any time I have my project again import Eclipse (position if I reinstall Eclipse, or change the project), almost all overridden methods are not formatted correctly, causing the error:

The method must override a superclass method which must override the superclass method

It may be noteworthy to mention this is with Android projects - for whatever reason, the method argument values are not always populated, so I have to manually populate them myself. It is worth noting that this is the Android project - for whatever reason The method parameter values are not always filled, so I had to manually fill them. For instance: For example:

list.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {

    //These arguments have their correct names
    public void onCreateContextMenu(ContextMenu menu, View v, 
                                    ContextMenuInfo menuInfo) {                 
    }

});

It will be initially populated like this: initially filled as follows:

list.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {

    //This methods arguments were not automatically provided    
    public void onCreateContextMenu(ContextMenu arg1, View arg2,
                                    ContextMenuInfo arg3) {
    }

});

The odd thing is, if I remove my code, and have Eclipse automatically recreate the method, it uses the same argument names I already had, so I do not really know where the problem is, other then it auto-formatting the method for me. the strange thing is, if I remove my code and let Eclipse automatically re-creation method, which uses the same argument I already have a name, so I do not really know where the problem, in addition to its automatic formatting methods I.

This becomes quite a pain having to manually recreate ALL my overridden methods by hand. This will need to manually re-create all overridden methods, it becomes very painful. If anyone can explain why this happens or how to fix it .. I would be very happy. If someone can explain why this happens or how to fix it ...... I would be very happy.

Maybe it is due to the way I am formatting the methods, which are inside an argument of another method? Perhaps this is because of the way I format method, which is within the parameters of another method?


#1st Floor

Reference: https://stackoom.com/question/72YU/ Eclipse project import after - must override the superclass method - error


#2nd Floor

This is my second time encounter this problem . This is the second time I encountered this problem. first time according the alphazero's recommendation it worked. for the first time on the recommendation of alphazero it worked. but in the second time I set to 1.6 it do not work it just like 'CACHE' this error after clean and rebuild. But the second time I did not set it appear like 'CACHE' 1.6 when the clean-up and reconstruction after this error.

Try to switch off 'Build Automatically' as Rollin_s said -> error still here! Try turning off 'auto-build' because Rollin_s say -> Error still here!

So I removed the problem project (already set to 1.6) from Package Explorer and import it again -> it start a rebuild and no error this time so I deleted the problems the project from the Package Explorer (already set to 1.6) and import again - > it began rebuilding and this time no errors

Hope this help someone hope this helps


#3rd floor

The Eclipse IS defaulting to the Java 1.5 and you have have classes implementingLearn interface Methods (Which in the Java 1.6 CAN BE annotated with @Override, But in the Java 1.5 CAN only BE Applied to Methods overriding A the superclass for Method,). The Eclipse default Java 1.5, and you have to implement the interface class (Java 1.6 may be used in the process of @Overrideannotated, but only in Java 1.5 superclass method applied covering method).

Go to your project / IDE preferences and set the Java compiler level to 1.6 and also make sure you select JRE 1.6 to execute your program from Eclipse. Go to Project / IDE preferences and Java compiler level is set to 1.6, and make sure JRE 1.6 to execute the program from Eclipse.


#4th floor

In my case, none the solutions above works. In my case, these solutions are ineffective. I have to checkout my source code to another folder. I have to check out my source code to another folder. From eclipse select File> Switch workSpaces> Other ... and then import code to the new workspaces. Select File> Switch workSpaces> Other ... from the eclipse and then the code into a new workspace. . it works after that it works after.


#5th Floor

The answer by Paul worked for me partially . Paul's answer in part to work for me. I still had one error then. I was also a mistake. So, in addition to that, I also had to go to Properties-> Project Facets and there set the Java version from 1.5 to 1.6. Therefore, in addition, I also have to go to Properties-> Project Facets, and Java set version 1.5 to 1.6.

Maybe that helps. Maybe it helpful.


#6th floor

Fixing must override a super class method error is not difficult, You just need to change Java source version to 1.6 because from Java 1.6 @Override annotation can be used along with interface method. Repair must override the superclass method error is not difficult, you only need to change Java source version 1.6, because you can use from Java 1.6 @Override comments with interface methods. In order to change source version to 1.6 follow below steps: To change the source version 1.6, follow these steps:

  1. Select Project, Right click, Properties select Project, right-click Properties
  2. Select Java Compiler and check the check box "Enable project specific settings" select Java Compiler and check "Enable project specific settings" checkbox
  3. Now make Compiler compliance level to 1.6 now enables the compiler compliance level of 1.6
  4. Apply changes Apply changes
Original articles published 0 · won praise 73 · views 550 000 +

Guess you like

Origin blog.csdn.net/w36680130/article/details/105250739