import org.apache.commons.lang3.reflect.FieldUtils;
import org.apache.commons.lang3.reflect.MethodUtils;
public class ReflectionExample {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public static void main(String[] args) throws NoSuchMethodException, IllegalAccessException, NoSuchFieldException {
ReflectionExample example = new ReflectionExample();
FieldUtils.writeField(example, "name", "John Doe", true);
String name = (String) MethodUtils.invokeMethod(example, "getName");
System.out.println(name);
}
}