In Java args
contains the supplied command-line arguments as an array of String
objects.
(在Java中, args
包含作为String
对象数组提供的命令行参数 。)
In other words, if you run your program as java MyProgram one two
then args
will contain ["one", "two"]
.
(换句话说,如果您以java MyProgram one two
运行您的程序,则args
将包含["one", "two"]
。)
If you wanted to output the contents of args
, you can just loop through them like this...
(如果要输出args
的内容,可以像这样循环遍历它们...)
public class ArgumentExample {
public static void main(String[] args) {
for(int i = 0; i < args.length; i++) {
System.out.println(args[i]);
}
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…