package cn.itcast.day1;
import java.lang.reflect.Method;
public class Main方法 {
public static void main(String[]args)throws Exception{
String startingClassName = args[0];
Method mainMethod = Class.forName(startingClassName).getMethod("main", String[].class);
mainMethod.invoke(null, new Object[]{new String[]{"111","222","333"}});
}
}
//定义一个类
class TextArguments{
public static void main(String[]args){
for(String arg : args){
System.out.println(arg);
}
}
} |
|