Unnecessary @SuppressWarnings("unused") Unnecessary @SuppressWarnings("unused") java java

Unnecessary @SuppressWarnings("unused")


In the code in your question, the @SuppressWarnings("unused") annotation is unnecessary because the method is either overriding another method from a superclass or implementing an interface. Even if you don't actually use the whatever parameter it's mandatory to declare it, otherwise the @Override annotation will produce an error (you'd be changing the signature of the overridden method if you removed the parameter.)

In some older versions of Eclipse the code as shown would not cause a warning, but in more recent releases it does. I believe it's a valid warning, and I'd rather remove the @SuppressWarnings("unused") in this case.


Go to

WindowPreferencesJavaCompilerErrors/WarningsAnnotations.

And select Ignore for Unused '@SuppressWarnings` token.


Alternatively, if you think it's more correct to delete the SuppressWarnings annotation:

Window -> Preferences -> Java -> Compiler -> Errors/Warnings -> Unnecessary code -> Value of parameter is not used

and select Ignore in overriding and implementing methods