> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Java Override Annotation

The `@Override` annotation is a built-in Java marker annotation applied to a method declaration to indicate that the method is intended to override or implement a method declared in a superclass or interface. It functions as a strict compiler directive, triggering compile-time signature verification against the parent type hierarchy.

## Technical Specifications

* **Package:** `java.lang.Override`
* **Target:** `@Target(ElementType.METHOD)` – It can only be applied to methods. Applying it to classes, fields, or variables results in a compilation error.
* **Retention:** `@Retention(RetentionPolicy.SOURCE)` – It is retained only in the source code and is discarded by the compiler. It is not written to the `.class` file and is unavailable at runtime via reflection.

## Syntax

```java theme={"dark"}
@Override
[access_modifier] [return_type] [method_name]([parameters]) {
    // method body
}
```

## Compiler Mechanics and Verification Rules

When the Java compiler encounters the `@Override` annotation, it performs a strict lookup within the type hierarchy. The compilation succeeds only if all the following conditions are met:

1. **Signature Matching:** The compiler searches the direct superclass and all implemented interfaces for a method with an identical name and matching parameter types. The parameter types must match exactly after type erasure.
2. **Return Type Compatibility:** The return type of the annotated method must be identical to, or a subtype of (covariant return type), the return type declared in the overridden method.
3. **Access Modifiers:** The annotated method cannot assign a more restrictive access modifier than the method it overrides (e.g., a `protected` method in the superclass cannot be overridden as `private`).
4. **Exception Handling:** The annotated method cannot declare any new or broader checked exceptions that are not declared by the overridden method.

If the compiler fails to find a matching method in the supertype hierarchy, or if any of the overriding rules are violated, it throws a fatal compile-time error: `method does not override or implement a method from a supertype`.

## Interface Implementation

Prior to Java 1.6, the `@Override` annotation was restricted exclusively to overriding methods from a superclass. As of Java 1.6 and later, the compiler specification was updated to allow and verify the `@Override` annotation on methods that implement a declared method from an interface.

```java theme={"dark"}
public interface Executable {
    void execute();
}

public class Task implements Executable {
    @Override
    public void execute() {
        // Compiler verifies 'execute()' exists in the Executable interface
    }
}
```

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor Java Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
