Java – @override annotation

java

Do I need to put @Override annotation when I implement an interface (not override an abstract class)?

And what does @Override annotation achieve?

Best Answer

In Java 5, you must not add @Override when implementing a method inherited from an interface, in Java 6, you should (or you'll get a compiler warning).

@Override asserts that a method is intended to override something, and will cause the compiler to notify you should this not or no longer be the case, for instance because the method you are overriding has been renamed.