The code snippet below gets all the fields of MyClass and displays the attribute name, type, modifiers, class and super class.

Java Code:
try {
Class c = Class.forName("MyClass");
Field list[] = c.getDeclaredFields();
for (int i = 0; i < list.length; i++) {
Field fld = list[i];
System.out.println("Class: "
+fld.getDeclaringClass());
System.out.println("Super Class: "
+fld.getDeclaringClass().getSuperclass());
System.out.println("Attribute name: " +
fld.getName());
System.out.println("Data type: " + fld.getType());
int mod = fld.getModifiers();
System.out.println("Modifiers: "
+Modifier.toString(mod));

System.out.println("======================================");
}
}
catch (Throwable e) {
System.err.println(e);
}