1.获得setter,getter方法
MyObject myObject = new MyObject();
//反射调用getter方法
Method getMethod = myObject.getClass().getMethod("get" + "MyPropValue");
String res = getMethod.invoke(myObject).toString();
//反射调用setter方法
Method method = myObject.getClass().getMethod("set" + "MyPropValue", String.class);
method.invoke(myObject, "Value");
标签:反射,myObject,getClass,getMethod,Method,setter
From: https://www.cnblogs.com/lwx11111/p/17635989.html