22.14 Annotations

Annotations

Overview

Annotations provide metadata about the program and are used by the compiler and runtime.

Topics

Examples

@Override
public String toString() {
    return "This is an example";
}

@Retention(RetentionPolicy.RUNTIME)
@interface MyAnnotation {
    String value();
}

@MyAnnotation(value = "Example")
class MyClass {}

Tags

#java #annotations #metadata