
在学习Java的时候,一些细节性的小问题往往会让人困惑不已,比如说在接收参数的时候。
如果你写的程序需要接收参数才能运行,而且你又没有给默认的参数,那么就会引起这个错误:
1 |
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 |
比如说你的代码是这样:
1 2 3 |
public static void main (String[] args) { new SomeClass(args[0]); } |
这时候就需要在运行程序时传入参数。这不难,难的是在 ecl[……]