Sunday, October 28, 2012

Retrieve Constructor Information of class using Java Reflection APIs

In order to retrieve Constructor information, just create object of class and call
getConstructors() api.

Java Program to retrieve Constructor Information using Java Reflection API :

Constructor[] constructor = originalClassObj.getConstructors();
System.out.println("Constructor used - ");
for (int i = 0; i < constructor.length; i++) {
    System.out.println(constructor[i].getName());
}

Author : Anuj Patel
Blog : http://goldenpackagebyanuj.blogspot.in/

No comments:

Post a Comment