import java.lang.reflect.Method; public class ReflectionUtil { public static void invokeMethod(Object obj, String methodName) throws Exception { Class<?> clazz = obj.getClass(); Method method = clazz.getMethod(methodName); if (method == null) { throw new NoSuchMethodException(methodName); } method.invoke(obj); } }


上一篇:
下一篇:
切换中文