Java by API/java.lang.annotation/Retention

Материал из Java эксперт
Перейти к: навигация, поиск

java.lang.annotation.Retention (how long annotations with the annotated type are to be retained)

   <source lang="java">
    

import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @Retention(RetentionPolicy.RUNTIME) @interface MyAnnotation {

 String stringValue();
 int intValue();

} public class Main {

 @MyAnnotation(stringValue = "Annotation Example", intValue = 100)
 public static void myMethod() {
 }

}



 </source>