Annotation interface indicates a method
Class<? extends Annotation> annotationType()
which has zero information 1 javadoc . I wonder what it's good for. All that I could find was a question, but in fact it is not needed (as the two upper answers below are accepted).
This allows us to use
a.annotationType().equals(MyAnnotation.class)
but
a instanceof MyAnnotation
performs the same task ... except when it ais an instance of a class that implements several annotations, but has anyone seen such a beast?
If it ais an instance class A implements MyAnnotation, YourAnnotation, then the two above tests are not equivalent, but the question is which one is better ...
(*) It looks like getX () returns x.