有三个类,Human,Head,Body,请问如何用反射获取Human中的Head中的属性(eye,nose)?
如下:
public class Human {
private Head head;
private Body body;
public Head getHead() {
return head;
}
public void setHead(Head head) {
this.head = head;
}
public Body getBody() {
return body;
}
public void setBody(Body body) {
this.body = body;
}
}
public class Head {
private String eye;
private String nose;
public String getEye() {
return eye;
}
public void setEye(String eye) {
this.eye = eye;
}
public String getNose() {
return nose;
}
public void setNose(String nose) {
this.nose = nose;
}
}
public class Body {
private String arm;
private String leg;
public String getArm() {
return arm;
}
public void setArm(String arm) {
this.arm = arm;
}
public String getLeg() {
return leg;
}
public void setLeg(String leg) {
this.leg = leg;
}
}