admin 管理员组

文章数量: 1086019

java class.getmethod

java 反射使用 Class.getMethod 应注意 记录下

Method method= clazz.getMethod(setMethodName,propertiesClass);

如果使用该方法 会不能获取以多态方式传入的参数

会抛异常 java.lang.NoSuchMethodException

比如:

public class Student {

private String name;

private int age;

private List list = new ArrayList();

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public int getAge() {

return age;

}

public void setAge(int age) {

this.age = age;

}

public List getList() {

return list;

}

public void setList(List list) {

this.list = list;

}

}

public static void main(String[] args) {

try {

Class> clazz

本文标签: java classgetmethod