引用:http://blog.csdn.net/ahwr24/article/details/7255379
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) {
}