Annotations in Java provide metadata about the code. They do not change program execution directly, but they help the compiler, tools, and frameworks understand how the code should be treated.
@ symbolJava provides built-in annotations and also allows developers to create custom annotations. Annotations can be processed at compile-time or runtime using reflection.
// Using a built-in Java annotation
@Override
public String toString() {
return "Hello Annotations";
}
The @Override annotation tells the compiler that the method must override a method from its superclass. If it does not, the compiler throws an error.
@Override when overriding methods@Override@Override and observe compiler behavior@Deprecated