我正在尝试将参数传递给 java 类主方法,我想使用 eclipse 传递参数,所以我去了
run -> run configuration -> program arguments
我写下了我的论点
exp grammar
但是每当我运行时都会出现此错误,
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
at LL.main(LL.java:146)
这意味着它看不到第二个参数“grammar”
,有人知道为什么以及如何解决这个问题吗?
编辑,这是我的主要方法
public static void main(String[] args) throws IOException {
String exp = args[0] + '$';
LL input = new LL(exp, Grammar.fromFile(args[1]));
try {
input.lLParse();
} catch (Exception e) {
System.out.println(e);
System.exit(1);
}
}
最佳答案
在运行 -> 运行配置 -> Java 应用程序 -> 参数
中输入以空格
分隔的输入
关于java - 如何在 Eclipse 中将参数传递给 main 方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30181479/