试图调用Java文件,并已被要求进行,以便如果Args [0]在终端调用中为空,则应返回所有对象。无法使其正常工作而不会遇到错误。
else if(args[1]==null){
System.out.println("Printing information on all cars.");
for (Bil l : bilArrayList){
System.out.println(l.toString());
}
}
不知道代码的详细信息,我建议您先检查args
的大小:
if(args.length> 0) {
//It depends on the size of the argument you wanna check.
//Might be args.length > 1 if you wanna make sure at least 2 elements in the args array
//doSomething
} else {
//doSomethingElse
}