
-----------------------------------
xtreemboarder
Wed Mar 21, 2007 9:08 pm

Why does this give me an error?
-----------------------------------
private static int countMoves (char
It throws an array index out of bounds exception... why?[/quote]

-----------------------------------
rdrake
Wed Mar 21, 2007 9:13 pm

RE:Why does this give me an error?
-----------------------------------
Let's look at how you declared the for loops. for (int i = 0 ; i < maze.length ; i++)
for (int j = 0 ; i < maze [1].length ; j++)Hm... the second for loop seems a wee bit off.  Change the i to j, and what's up with the one in "[1].length"?

-----------------------------------
Clayton
Wed Mar 21, 2007 9:18 pm

Re: Why does this give me an error?
-----------------------------------
because he seems to have a 2 - dimensional array, and he wants to find the upper bounds of the second dimension of the array, he simply has to find the upper bound of the array from an element of the first array. Recall that 2D arrays are really just an array of an arrays :P

-----------------------------------
klopyrev
Wed Mar 21, 2007 10:13 pm

Re: Why does this give me an error?
-----------------------------------
Aside from the fact that the line in the second for loop should be j< not i