标题: JavaBean重载函数的问题 [打印本页] 作者: 黑马张旭明 时间: 2012-10-12 18:03 标题: JavaBean重载函数的问题 public class Human {
private String name;
private int lv;
public Human(String name ,int lv){
this.name = name;
this.lv = lv;
}
public void setLv(int lv){
this.lv = lv;
}
public void setLv(String s){
//这里故意加了个重载的setAge方法
}
}
public static void main(String[] args)throws Exception{
Human h = new Human();
PropertyDescriptor pd = new PropertyDescriptor("name",Human.class);
Method methodSetName = pd.getWriteMethod();
methodSetName.invoke(h, "zhaoliu");