The code should test the length of the array BEFORE trying to index into it.

Thanks but I still don't understand how to use it, (sorry im new to all of this) where do I put this line of code?

11-30-2013, 12:08 AM

Norm

Re: Array Out of Bounds Exception

That code was a demo of how to get an array index out of bounds exception.
Your code assumes that the the array: args has 2 elements. The code needs to test the length of the array BEFORE trying to access the first 2 elements. If the array length is < 2 it should NOT try to access them.
Test the length, if < 2, print an error message to the user and exit the program because the program needs 2 argument values to execute correctly.