I have written below the Custom Annotation.
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface MyAnnotation {
String value();
}
and am using the annotation as below.
@MyAnnotation("someValue")
public void someMethod(){
}
above code is working fine without any issues. But in the annotation class, value() method name i have to reanme. Can i do as below?
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface MyAnnotation {
String name();
}
I tried doing but eclipse is giving the compilation error.
- The attribute value is undefined for the annotation type
MyAnnotation
- The annotation @MyAnnotation must define the attribute
name
Any reason?