更新时间:2023-11-05 16:21:04
In Java args
包含提供的 命令行参数 作为 String
对象的数组.
In Java args
contains the supplied command-line arguments as an array of String
objects.
换句话说,如果你以 java MyProgram one two
运行你的程序,那么 args
将包含 ["one", "two"]
.
In other words, if you run your program as java MyProgram one two
then args
will contain ["one", "two"]
.
如果你想输出args
的内容,你可以像这样循环它们......
If you wanted to output the contents of args
, you can just loop through them like this...
public class ArgumentExample {
public static void main(String[] args) {
for(int i = 0; i < args.length; i++) {
System.out.println(args[i]);
}
}
}