假设您要调用MyClass.myMethod(int x);
Method m = MyClass.class.getDeclaredMethod("myMethod", Integer.TYPE);m.setAccessible(true); //if security settings allow thisObject o = m.invoke(null, 23); //use null if the method is static
假设您要调用MyClass.myMethod(int x);
Method m = MyClass.class.getDeclaredMethod("myMethod", Integer.TYPE);m.setAccessible(true); //if security settings allow thisObject o = m.invoke(null, 23); //use null if the method is static