How to obtaion annotations at runtime using reflection?
This example demonstrate how to obtaion annotations of a class and methods. We use the reflection API to get class and method information from where we can read information about annotation attached to the class or the method.
You can find the
HelloAnno annotation that we use above on the following example: How to create a simple annotation?.
The result of our program is:
Annotation Type: interface com.javacoderanch.example.annotation.HelloAnno
Anno Value : Hello
Anno GreetTo: Universe
Anno Value : Hi
Anno GreetTo: Alice