Creating Annotations : Annotations Create « Language « Java Tutorial

Annotation is created based on the interface.

  1. Adding '@' before the keyword interface to declare an annotation type.
  2. All annotations consist only method declarations.
  3. These methods act much like fields.

Our first annotation type:

// A simple annotation type.
@interface MyAnnotation {
  String stringValue();
  int intValue();

1.11.Annotations Create
1.11.1.Creating Annotations
1.11.2.Define new annotation type
1.11.3.Specifying a Retention Policy
1.11.4.default values in an annotation.