Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 994
Shandan Spencer Avatar asked Oct 23 '25 06:10

Shandan Spencer


1 Answers

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.

like image 58
Yogendra Singh Avatar answered Oct 25 '25 19:10

Yogendra Singh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!