@Override
annotation is doing anything useful
in the following code excerpt:
interface Fun { public void f(int x); } //blah blah blah void moo() { Fun f = new Fun() { @Override public void f(int x) { // blah blah blah } } // blah blah blah }
Not really. The @Override
annotation helps catch cases where a child has
misdeclarations when overriding ancestor methods (page 173 (7th ed.) or 196 (8th ed.)).
However, an interface is implicitly abstract, as are all methods defined in the
interface (page 212 (7th ed.) or 243 (8th ed.)). An abstract class cannot be instantiated
(page EdPage(165, 188)), and a misdeclaration without an @Override
annotation would still result in a compilation-time error, although of a
different kind.
This page last modified on 31 March 2008. |
|