Search code examples
javaeclipseinterfaceimplementationsuperclass

The method must override or implement a superclass method


Quick question. I am using Eclipse and I am getting the The method must override or implement a superclass method error, except Eclipse is using compliance of Java 1.7.
Here is my Code:

public abstract class M4 implements Armory {

@Override
public Integer weaponAmmo(int wepAmmo) {
    wepAmmo = 10;
    return wepAmmo;
}

@Override
public Integer weaponDamage(int wepDamage) {
    wepDamage = 2;
    return wepDamage;
}

@Override
public String weaponName(String wepName) {
    wepName = "M4";
    return wepName;
}

And here is the interface Code:

public interface Armory {
        public Integer weaponAmmo(int wepAmmo);
        public Integer weaponDamage(int wepDamage);
        public String weaponName(String wepName);

    }

Any Ideas?


Solution

  • You don't need to use @override annotation in your method implementation as you are not overriding the methods. You are just implementing the interface methods. This annotation is required when your override any super class methods.

    Remove the @Override annotations and it should be fine.