0

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?

Novice User
  • 3,552
  • 6
  • 31
  • 56

0 Answers0