This method returns this element's annotation for the specified type if such an annotation is present, else
null.
package com.logicbig.example.clazz;
public class GetAnnotationExample {
public static void main(String... args) {
Deprecated annotation = MyClass.class.getAnnotation(Deprecated.class);
System.out.println(annotation);
System.out.println(annotation.annotationType().getSimpleName());
}
@Deprecated
private static class MyClass {
}
}
Output
@java.lang.Deprecated()
Deprecated