6

Possible Duplicate:
What’s “@Override” there for in java?

Since Java 1.5 this annotation was incorporated to the language to be used on methods that overwrite a superclass methods.

Now, what changes in a method that uses this annotation to one that doesn't use it? Is this just convention?

Assuming, obviously, that both be methods that overwrite a method from its superclass...

Community
  • 1
  • 1
  • also see: http://stackoverflow.com/questions/94361/when-do-you-use-javas-override-annotation-and-why – Alex Dec 02 '12 at 10:36

1 Answers1

7

@Override creates a compile-time check that a method is being overridden. This is very useful to make sure you do not have a silly signature issue when trying to override

It not only makes the compiler check but also documents the developer's intention.

if you override a method but don't use it anywhere from the type itself, someone coming to the code later may know the purpose. The annotation explains its purpose.

A good IDE will helpfully flag any method that overrides a method without @Override, so the combination of the two will help ensure that you're doing what you're trying to.

it also improves readability

Ravindra Bagale
  • 17,226
  • 9
  • 43
  • 70