The code needs to test if the length of the args array is > 0. If it is NOT, the code should NOT try to access index 0.
A couple of solutions if the length < 1
Print out an error message to the...
Type: Posts; User: Norm
The code needs to test if the length of the args array is > 0. If it is NOT, the code should NOT try to access index 0.
A couple of solutions if the length < 1
Print out an error message to the...
The indexes for arrays start at 0 and go to the array length-1.
The first element in an array is at index 0.
You never posted the full text of the error message that shows what line the error...
Test the array's length BEFORE trying to index into the array.
If the array is not long enough, do NOT try to index into it.
The error message says that the array is empty (it does NOT have an element at index 0).
The code needs to test if the array has one or more elements BEFORE trying to access the first element.
Use...