Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 0

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:

For example, your code is:

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

The menu bar to find Run,Then select the run option

The menu bar to find Run,Then select the run option

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:

In the parameters tab, add parameter

In the parameters tab, add parameter

 

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

About the Author

R0uter

The non-declaration,I have written articles are original,Reproduced, please indicate the link on this page and my name。

Leave a Reply

Your email address will not be published. Required fields are marked *