Reflection: get type members in Java
Forums:
//SampleLib.MacBook - full class name
Class macType = Class.forName("SampleLib.MacBook");
//show methods
Method[] methods = macType.getMethods();
for (Method method : methods) {
System.out.println(method.getName());
}
//show fields
Field[] fields = macType.getFields();
for (Field field : fields) {
System.out.println(field.getName());
}
- Log in to post comments