Saturday, October 27, 2012

Retrieve Fields Information of class using java Reflection APIs

Using Java Reflecion APIs you can get fields information of class easily. just create object of class and get fields using getFields();

Java Program to retrieve fields information using java Reflection Apis :
Field[] fields = originalClassObj.getFields();
System.out.println("Fields used - ");
for (int i = 0; i < fields.length; i++) {
    System.out.println(fields[i].getName());
}

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