I am creating a custom annotation
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface MyFramework {
public Integer index() default null; // Compiler complains here
}
The compiler complains that null
is not allowed. I do not want to make the index field primitive type int
as it would not make sense. Is there a way to have a default null
value for annotation fields?