工具:IDEA
代码段:
//:chapter_four/src/main/java/Variableparameters.java public class Variableparameters { static void kebian(String...args) { System.out.println("String...args:"+args[2]); } public static void main(String...args) { for(String s:args) System.out.println("args:"+s); kebian("ss","sss","ssss"); kebian(new String[]{"1","2","3"}); } }
运行结果:
一个参数:
两个参数:
三个参数:
IDEA中的“命令行参数”功能路径如图: