Quantcast

What is the meaning of defining enums and fields inside annotation declarations?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

What is the meaning of defining enums and fields inside annotation declarations?

Mário Guimarães
Hello,

It seems it is possible to declare fields and enums inside the declaration of an annotation in Java. For example, javac compiles this:

 @interface ClassPreamble {
   public enum AnEnum {
        Value;
   }
   String aField = "";

   String author();
   String date();
   String currentRevision() default "";
   String lastModified() default "N/A";
   String lastModifiedBy() default "N/A";
   // Note use of array
   String[] reviewers();
}

What is the meaning / usefulness of defining enums and fields inside annotation declarations?

Thanks

Mário

Loading...