Java命令行参数
命令行参数是在执行时直接在命令行上跟随程序名称的信息。在Java程序中访问命令行参数非常容易。它们作为字符串存储在传递给main()的String数组中。
示例
以下程序显示了使用以下命令调用的所有命令行参数:
public class CommandLine {
public static void main(String args[]) {
for(int i = 0; i<args.length; i++) {
System.out.println("args[" + i + "]: " + args[i]);
}
}
}尝试执行此程序,如下所示-
$java CommandLine this is a command line 200 -100
输出结果
这将产生以下结果-
args[0]: this args[1]: is args[2]: a args[3]: command args[4]: line args[5]: 200 args[6]: -100
热门推荐
1 训练狗狗基础
2 怎么训练狗狗笑
3 怎么训练狗狗卧下
4 上海狗狗训练基地
5 训练狗狗排便
6 狗狗基础训练
8 如何训练狗狗装死
9 狗狗站姿训练
10 狗狗训练用品
11 训练狗狗吧
12 狗狗要怎么训练
13 怎么训练狗狗玩球
14 训练狗狗唤回
15 狗狗训练躺下
16 狗狗训练指令
17 狗狗的训练技巧
18 狗狗不好训练