+ 2
Why this occur in java?
Exception in thread "main"java.lang.ArrayIndexOutOfBoundsException: 0 https://code.sololearn.com/cOw1cwjzvz6d/?ref=app
4 odpowiedzi
+ 3
Martin Taylor is ryt!
That input in the main method is the command line argument that is not accessible in SoloLearn!
+ 1
ArrayIndexOutOfBoundsException as it's telling means you are trying to access beyond array length ex: if it have 5 values so max index possible is 5-1=4 accessing 5 or above index will raise exception..
In your program, you just assigned string array arg[], not yet given or assigned any values.. Value at index is not yet given or assigned..
Here may compiler setting giving a value '-' through command line argument. This can not be converted to Integer farmat. So invalid argument hence exception is raising..
You cannot pass values here through command line as arguments..
0
Your code is not clear .
What do you want to do ?
Are you about to do something with comman line argument ?
Or just want to take input from user and check less than 100 ?
You got exception because you tried to convert string to Integer .
If you want to take input from user in console, learn about Scanner class and try again.
You can learn with sololearn lesson with this link
https://www.sololearn.com/learn/Java/2220/
Good luck:)