Override

  • @Override is an annotation used to indicate that a method is intended to override a method in its supertype.

  • The compiler generates an error if the annotated method doesn't override a supertype method or have an override-equivalent signature to a public method in Object.

  • @Override helps ensure that methods are correctly overridden, promoting code clarity and preventing accidental errors.

  • This annotation inherits methods like annotationType(), equals(), hashCode(), and toString() from the Annotation interface.

public abstract @interface Override implements Annotation

Indicates that a method declaration is intended to override a method declaration in a supertype. If a method is annotated with this annotation type compilers are required to generate an error message unless at least one of the following conditions hold:

  • The method does override or implement a method declared in a supertype.
  • The method has a signature that is override-equivalent to that of any public method declared in {@linkplain Object}.

Inherited Method Summary