java 参数为方法进行传递

421 阅读1分钟

参数形式:(Method method

调用形式:这个方法包含的类.class.getDeclaredMethod(方法名称,参数类型.class)

如下

(被调方法所在类名称.class.getDeclaredMethod("方法名",int[].class,int.class)

方法内部调用:

method.invoke(method.getDeclaringClass().newInstance(), arr, n); 

//  arry,n 为参数方法的参数