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());
    }
  }
}




















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable