1. Create a program that outputs command-line arguments:
(1) Create a program that outputs every command-line argument, then displays the arguments and their number.
(2) You should use the array variable length to retrieve the length of the array.
(1) Create a program that outputs every command-line argument, then displays the arguments and their number.
(2) You should use the array variable length to retrieve the length of the array.
是不是就是输出aaa bbb 和ccc啊?
{
public static void main(String[] args)
{
if(args.length==0)
{
System.out.println("No Command Line arguments!");
return;
}
for(int i=0; i<args.length; i++)
{
System.out.println(i+","+args[i]);
}
}
}运行:javac test.javajava test aaa bbb ccc ddd输出:
0,aaa
1,bbb
2,ccc
3,ddd