0 votes
1 view
in Java by (3.5k points)

Anytime I have to re-import my work into Eclipse (if I reinstalled Eclipse, or changed the location of the projects), almost all of my overridden methods are not formatted correctly, creating the error:

The program must override a superclass method

It may be noteworthy to mention this is with Android projects - for whatever cause, the method argument values are not always populated, so I have to manually populate them myself. For instance:

list.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {

    //These arguments have their correct names

    public void onCreateContextMenu(ContextMenu menu, View v, 

                                    ContextMenuInfo menuInfo) {                 

    }

});

will be initially populated like this:

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 delete my code, and have Eclipse automatically recreate the method, it uses the same argument names I already had, so I don't know where the problem is, other then it auto-formatting is the method for me.

This becomes quite a pain having to manually recreate ALL my overridden methods by hand. If anyone 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?

1 Answer

0 votes
by (2k points)

It’s happening because of the Eclipse is inscribed to Java 1.5 and you have classes implementing interface programs (which in Java 1.6 can be annotated with @Override, but in Java 1.5 can only be performed to methods overriding a superclass method).

Follow these steps to fix it:

  • Select Project, Right-click, Properties

  •  Select Java Compiler and check the checkbox "Enable project specific settings"

  •  Now make Compiler compliance level to 1.6

  •  Apply changesimage

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...