Experiencing Java.lang.Array Index Out Of Bounds Exception Error

Asked By 40 points N/A Posted on -
qa-featured

While coding a java program, I have came across this strange error during the compilation of program saying "Java.lang.ArrayIndexOutOfBoundsException."

I am also pasting my specific fragment of code.

I will be very obliged if responded.

SHARE
Answered By 0 points N/A #97423

Experiencing Java.lang.Array Index Out Of Bounds Exception Error

qa-featured

Hi Majidarao

This error indicates that array has been accessed by some illegal index.

Now what does illegal index name means here?

It means that you are trying to access an index of array which does not exist actually.

To solve this I will recommend you to go basic concepts of array. In java Array is basically an object.

Link may help you to understand.

You have to check that you are not referring any index which does not exist in your array. Remember that when you create array by writing

int[] intArray = new int[10];

The values of indexes will be from 0 to 9 for the above array.

So make sure that you are not referring index greater than i.e. 9 for the above example.

you can post your code.

Best of luck

Related Questions