- 代码一:
- class TestArgument1 {
- public static void main(String[] args) {
- for (String arg : args) {
- System.out.println(arg);
- }
- }
- }[code]代码二:
- import java.lang.reflect.Method;
- public class Refelctmain {
- public static void main(String[] args) throws Exception {
- String startingClassName = args[0];
- Method methodmain = Class.forName(startingClassName).getMethod("main",String[].class);
- System.out.println(methodmain.invoke(null,new Object[]{new String[]{"aaa","bbb"}}));
- }
- }
复制代码 [/code] |