First, the steps:
1 using the PropertyDescriptor class to get the property descriptor object
PD references the name attribute of Student
propertydescriptor pd = new PropertyDescriptor ("name", Student.class);
2) through the Getwritemethod () method +invoke () method to set
Equivalent to getting SetName () method
m = Pd.getwritemethod ();
M.invoke (Stu, "Berrry");
3) through the Getreadmethod () method +invoke () method to obtain
Equivalent to getting GetName ()
m = Pd.getreadmethod ();
String returnvalue = (string) m.invoke (s, null);
Second, through the beaninfo to traverse all the attributes and set
1 The BeanInfo object is obtained by the static method Getbeaninfo () method of Introspector class
BeanInfo represents all the property collection objects of the Student object
BeanInfo bi = introspector.getbeaninfo (student.class);
2 Get all property collections
Gets the collection of all properties of the student object
propertydescriptor[] pds = Bi.getpropertydescriptors ();
3) As above: through the Getwritemethod () and Getreadmethod () + Invoke () method to do the appropriate operation.