有这样一段测试代码:
package org.com.Test;import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;/**
 * @author Administrator
 * 
 */
public class GTest {
public static void show(String... s) {
System.out.println(s.length);
} /**
 * @param args
 * @throws ClassNotFoundException 
 * @throws NoSuchMethodException 
 * @throws SecurityException 
 * @throws InstantiationException 
 * @throws InvocationTargetException 
 * @throws IllegalAccessException 
 * @throws IllegalArgumentException 
 */
public static void main(String[] args) throws ClassNotFoundException, 
SecurityException, NoSuchMethodException, IllegalArgumentException,
IllegalAccessException, InvocationTargetException, InstantiationException {
Class<?> gtClass=Class.forName("org.com.Test.GTest");
Method method=gtClass.getMethod("show", String[].class);
                //method.invoke(gtClass.newInstance(),"1","2");
                //method.invoke(gtClass.newInstance(),new String[]{"1","2"});
}
}
最后执行这个方法时候这里要怎么给参数这个方法才能正常执行?
注释的这两行一个是报:
Exception in thread "main" java.lang.IllegalArgumentException: wrong number of arguments
还有一个报:
Exception in thread "main" java.lang.IllegalArgumentException: argument type mismatch
请指点一下,谢谢!