# Debugging ArrayIndexOutOfBoundsException

**URL:** https://discourse.processing.org/t/debugging-arrayindexoutofboundsexception/29988
**Category:** Coding Questions
**Created:** [May 9, 2021, 5:10pm UTC](https://discourse.processing.org/t/debugging-arrayindexoutofboundsexception/29988 "2021-05-09T17:10:09Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![elenanito](https://avatars.discourse-cdn.com/v4/letter/e/cab0a1/32.png) [@elenanito](https://discourse.processing.org/u/elenanito)
#### Post date: [May 9, 2021, 5:10pm UTC](https://discourse.processing.org/t/debugging-arrayindexoutofboundsexception/29988/1 "2021-05-09T17:10:09Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)
#### Post date: [May 9, 2021, 6:01pm UTC](https://discourse.processing.org/t/debugging-arrayindexoutofboundsexception/29988/2 "2021-05-09T18:01:14Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![TfGuy44](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tfguy44/32/41_2.png) [@TfGuy44](https://discourse.processing.org/u/TfGuy44)
#### Post date: [May 9, 2021, 6:27pm UTC](https://discourse.processing.org/t/debugging-arrayindexoutofboundsexception/29988/3 "2021-05-09T18:27:17Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [May 9, 2021, 6:57pm UTC](https://discourse.processing.org/t/debugging-arrayindexoutofboundsexception/29988/4 "2021-05-09T18:57:24Z")

</div>

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

Or use debugger

---

<div class="post-metadata">

### Author: ![elenanito](https://avatars.discourse-cdn.com/v4/letter/e/cab0a1/32.png) [@elenanito](https://discourse.processing.org/u/elenanito)
#### Post date: [May 9, 2021, 7:12pm UTC](https://discourse.processing.org/t/debugging-arrayindexoutofboundsexception/29988/5 "2021-05-09T19:12:12Z")

</div>

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

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [May 9, 2021, 10:01pm UTC](https://discourse.processing.org/t/debugging-arrayindexoutofboundsexception/29988/6 "2021-05-09T22:01:40Z")

</div>

Hello,

Adding a couple more useful links to the topic:

- [https://forum.processing.org/two/discussion/8093/frequently-asked-questions](https://forum.processing.org/two/discussion/8093/frequently-asked-questions) (See Exceptions)

- [Home · processing/processing Wiki · GitHub](https://github.com/processing/processing/wiki) (See Common Errors)

`:)`
