Annotation access modifier - public vs abstract

前端 未结 5 652
夕颜
夕颜 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: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.

提交回复
热议问题