@Override annotation, I’m looking at you
Being out of touch with Java coding and moving between Java 5 and 6 can be a great way to assume yourself. Couple of days back I stumbled upon a fairly well know Java 5 feature, @Override annotation. Annotations were introduced in Java 5. According to the JavaDoc
public @interface OverrideIndicates that a method declaration is intended to override a method declaration in a superclass. If a method is annotated with this annotation type but does not override a superclass method, compilers are required to generate an error message.
One would read this and think the following code should work perfectly fine:
interface I {
void m1();
}
class C implements I {
@Override
public void m1() {
}
}
But guess what? In Java 5, the compiler gives the following error: “The method m1() of type C must override a superclass method”

