// String.class here is the parameter type, that might not be the case with you
Method method = clazz.getMethod("methodName", String.class);
Object o = method.invoke(null, "whatever");
如果方法是私有的,请使用getDeclaredMethod()
而不是getMethod()
.并在方法对象上调用setAccessible(true)
.