public class ReflectionTest {
public static void main(String[] args) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
// TODO Auto-generated method stub
ReflectionTest t = new ReflectionTest();
Method method[]= t.getClass().getMethods();
System.out.println(method.length);
for(int i=0;i<=method.length;i++){
method[i].invoke(t);
}
}
public void abc(){
System.out.println("abc");
}
public void xyz(){
System.out.println("XYZ");
}
}
结果错误的数字显示:Method.invoke抛出java.lang.IllegalArgumentException异常:参数
abc
xyz
Exception in thread "main" java.lang.IllegalArgumentException: wrong number of arguments
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.selenium.test.ReflectionTest.main(ReflectionTest.java:21)
请帮助我如何处理这个
你的上限为环太大,它应该更像我
Smutje