How read annotation at runtime using Java Reflection

In this article, We are going to see, how to read annotation values in runtime using Java Reflection.

  • Get class instance using getClass()

  • Assign annotated method from class instance using runtimeClass.getMethod() .

  • Get annotation instance using method.getAnnotation().

SOURCE:AuthorInfo.java

SOURCE:ReadAnnotationRuntime.java

OUTPUT:
Name :becbe
Description :A unique source for Java developers

SHARE

    Blogger Comment
    Facebook Comment

0 comments :

Post a Comment