Java - Annotation Member Annotation Type

Introduction

You can use an annotation type as the type of another annotation element value.

@interface Description { 
        Name name(); 
        Version version(); 
        String comments() default ""; 
} 
  

To provide a value for an element of an annotation type, create an annotation type instance.

@interface Version {
  int major();

  int minor();
}
@interface Name {
  String first(); 
  String last(); 
}
@interface Description { 
        Name name(); 
        Version version(); 
        String comments() default ""; 
} 

@Description(name=@Name(first="A", last="B"), 
            version=@Version(major=1, minor=2), 
            comments="Just a test class") 
 class Test { 
       // Code goes here 
}