When you learn Java,Some details of the small problems tend to be very confusing,When in receive parameters, for example。
If your program needs to receive arguments in order to run,And you did not give the default parameters,That can cause this error:
1 |
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 |
For example, your code is:
1 2 3 |
public static void main (String[] args) { new SomeClass(args[0]); } |
When you need to run the program at this point passed in the parameter。It's not difficult,In Eclipse, the difficulty is how to,Run is a command line command but no longer a button!
of course,This must be a configuration option (this time feel,CLI really convenient?)
Find RUN in the Eclipse menu bar menu,Then find the "run configuration" option。As shown below
Pop-up configuration window to the right to find Arguments tab,Click on tab,In the first text box to enter parameter!
As shown below:
Original article written by LogStudio:R0uter's Blog » Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 0
Reproduced Please keep the source and description link:https://www.logcg.com/archives/1080.html