我很怀疑我在这里很愚蠢,但我从未见过有人这样做过。在本课程中,他们不是在声明变量,而是使用main中声明的字符串数组参数。
static public void main(String[] args) {
RandomAccessFile admin;
byte init[] = {0};
if (args.length != 1)
System.err.println("usage: java {gate_bottom,gate_top}");
我的说明是 “为此,您需要指定一个参数。该参数应该是gate_bottom或gate_top”
我应该在哪里指定参数,以便args包含某些内容?
答案 0 :(得分:1)
if(args[0].equals("gate_bottom"))
else if(args[0].equals("gate_top"))
因此,当您调用myprogram.exe gate_bottom
或myprogram.exe gate_top
之类的程序时,条件将被触发