Debugging ArrayIndexOutOfBoundsException

I got this exception and the console says:

java.lang.ArrayIndexOutOfBoundsException: 8

at programName.function(projectName.java:84)

But there is nothing but comments on line 84 .

my program has over 2000 lines so, what is the fastest way to debug this exception?

I would normally start by identifying which method is causing the flaw, perhaps add a comment in each method with a debug bool condition. That way you can set them on and off.

Without seeing your code thats the best i can recommend, be as informative as you can with your comments.

You also know the bad index is 8, so you’re probably looking for an array somewhere that has a size of eight elements. Check for loops for <= instead of < signs.

1 Like

You have to look, processing shows the problem line in red / yellow

Or use debugger

UPDATE:
I had to recompile the program so the IDE correctly highlights in yellow the line that gives the exception.

1 Like

Hello,

Adding a couple more useful links to the topic:

:)

1 Like