22.14 Annotations
Annotations
Overview
Annotations provide metadata about the program and are used by the compiler and runtime.
Topics
- Built-in Annotations (
@Override,@Deprecated,@SuppressWarnings) - Custom Annotations
- Retention Policies
- Using Reflection with Annotations
Examples
@Override
public String toString() {
return "This is an example";
}
@Retention(RetentionPolicy.RUNTIME)
@interface MyAnnotation {
String value();
}
@MyAnnotation(value = "Example")
class MyClass {}