0
Java error array index out of bond
When try get value from command line argument https://code.sololearn.com/cDUc211U512u/?ref=app
5 Respostas
+ 3
It seems that codes running on Code Playground was ran without any command line argument passed, when I checked `args.length` it yields zero, the `args` array is empty.
+ 2
Do a check for `args.length` before tempting to get an element out of it, if the length yields non zero, then proceed with parsing a value (int) from it, probably using a try ... catch block just in case the number parsing failed. I'm not sure how fault tolerant `Integer.ParseInt` is, so please take care on that part.
+ 1
How solve it
+ 1
I don't think you can pass any runtime arguments when you run code on Sololearn. The alternative is to ask for user input via Scanner object.
+ 1
Thank u