Java Class.getAnnotations()
Syntax
Class.getAnnotations() has the following syntax.
public Annotation [] getAnnotations()
Example
In the following code shows how to use Class.getAnnotations() method.
// w w w . ja v a2 s . c om
import java.lang.annotation.Annotation;
public class Main {
public static void main(String[] args) {
Main cls = new Main();
Class c = cls.getClass();
Annotation[] a = c.getAnnotations();
for (Annotation val : a) {
System.out.println(val.toString());
}
}
}