引用:http://blog.csdn.net/ahwr24/article/details/7255379spa
try {
//獲得類對象
Class c = Class.forName("完整類名");
Object yourObj = c.newInstance();
//獲得方法
Method methlist[] = cls.getDeclaredMethods();
for (int i = 0; i < methlist.length; i++) {
Method m = methlist[i];
}
//獲取到方法對象,假設方法的參數是一個int,method名爲setAge
Method sAge = c.getMethod("setAge", new Class[] {int.class});
//得到參數Object
Object[] arguments = new Object[] { new Integer(37)};
//執行方法
sAge.invoke(yourObj , arguments);
} catch (Exception e) {
}.net