import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;/** *//**
* @author Dong
* 测试JAVA reflect机制
*/
public class TestRef{
/** *//**
* @param args
*/
public static void main(String[] args){
TestBean test = new TestBean();
Method[] methods = test.getClass().getMethods();
test.setAbc("---");
for(int i=0;iif(methods[i].getName().equalsIgnoreCase("getabc")){
try {
System.out.println(methods[i].invoke(test));
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}
}