Annotation access modifier - public vs abstract

前端 未结 5 650
夕颜
夕颜 2021-01-23 13:08

What is the difference between public and abstract modifier for an elements of annotation in Java.

For example we coul

相关标签:
5条回答
  • 2021-01-23 13:13

    Both of them are redundant. As described in the JLS the methods of an interface are abstract and public by default.

    0 讨论(0)
  • 2021-01-23 13:17

    There is no impact - it's just a redundant declaration. Same with interface's methods, for instance.

    0 讨论(0)
  • 2021-01-23 13:21

    In java annotation is a special type of interface. So it follows rules of interface and interface methods are by default public and abstract. In spite of default consideration, you could still add both public and abstract modifier explicitly. But it will be considered as redundant.

    Additionally if you declare a variable inside annotation, by default it will be a final and static variable.

    0 讨论(0)
  • 2021-01-23 13:23

    Every interface is implicitly abstract. The interface implicitly declares a public abstract member method.

    0 讨论(0)
  • 2021-01-23 13:35

    An annotation type is a special kind of interface. In an interface, all methods are implicitly both public and abstract, but is allowed to explicitly state that a method is public and/or abstract. Declaring an interface method as public or abstract has no effect, however.

    0 讨论(0)
提交回复
热议问题