日期:2014-05-18 浏览次数:20773 次
public class ExamplePO{
private String row1;
private String row2;
...
private String row100;
//然后是get和set方法
}
public class ExamplePO {
private String row1;
private String row2;
private String row3;
private String row100;
public String getRow1() {
System.out.println("getRow1()");
return row1;
}
public String getRow2() {
System.out.println("getRow2()");
return row2;
}
public String getRow3() {
System.out.println("getRow3()");
return row3;
}
public String getRow100() {
System.out.println("getRow100()");
return row100;
}
public static void main(String[] args) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, InstantiationException {
Method[] methods = ExamplePO.class.getDeclaredMethods();
for(Method method : methods){
String methodName = method.getName();
if(methodName != null && methodName.startsWith("get")){
method.invoke(ExamplePO.class.newInstance(), null);
}
}
}
}