Having trouble finding the cause of this ArrayIndexOutOfBoundsException
Discuss Having trouble finding the cause of this ArrayIndexOutOfBoundsException in the Java Help forum on Dev Shed. Having trouble finding the cause of this ArrayIndexOutOfBoundsException Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics.
Posts: 2,952
Time spent in forums: 1 Week 6 Days 2 h 34 m 5 sec
Reputation Power: 345
Can you post the full text of the error message that shows where the error happens.
How does the code try to keep the index from going past the end of the array?
What variable's value is too big?
Code:
sub[m][n] = a[i-dx/2 + m][j-dy/2 + n]; //#1 array index out of bounds exception
Which array? sub or a?
What is the value of the 4 indexes used with those arrays?
Add a println() statement to print out the values of those 4 indexes so you can see what their values are.