是有点模糊,仔细看也能看出来- package cn.itheima.day1;
- import java.lang.reflect.Method;
- public class Test01 {
- public static void main(String[] args) throws Exception {
- String startingClassName = "cn.itheima.day1.TestArguments1";
- Method main = Class.forName(startingClassName).getMethod("main", String[].class);
- System.out.println(main.invoke(null, (Object)new String[]{"111", "222", "333"}));
- }
- }
- class TestArguments1{
- public static void main(String args[]){
- System.out.println("length" + args.length);
- for(int i = 0; i < args.length; i++){
- System.out.println(args[i]);
- }
- }
- }
复制代码 输出结果:
length3
111
222
333
null
|