类的嵌套如何使用反射获取嵌套类的key value
如
public class PersonBean {
private String name;
private Student student;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Student getStudent() {
return student;
}
public void setStudent(Student student) {
this.student = student;
}
}
public class Student {
private String sex;
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
}
public static void main(String[] args) {
Student student=new Student();
student.setSex("男");
person.setStudent(student);
}
如何通过反射获取Student中属性、值呢(即 sex字段、和值)