is the following if statement valid?
if(0< maze[point.x][point.y] && maze[point.x][point.y] <= 5)
I wanted to say the array is greater than zero and equals to or less than 5.
Thanks!
Printable View
is the following if statement valid?
if(0< maze[point.x][point.y] && maze[point.x][point.y] <= 5)
I wanted to say the array is greater than zero and equals to or less than 5.
Thanks!
logically it should work, the && operator requires that both boolean statements must be true. Are you having troubles with it in your code or getting errors?
I tried to run the program and it gives me an error "ArrayIndexOutOfBoundsException -1".
it probably has to do with a loop around the if statement, if you post more of the code around the if statement i could take a look at it and see if i can tell what it is doing.
You can't compare an array to a scalar. What your code does is:Quote:
I wanted to say the array is greater than zero and equals to or less than 5.
"If the value at the index pair (point.x, point.y) of the 2d array 'maze' is greater than 0 and less than or equal to 5"
But apparently the index pair (point.x, point.y) is out of bounds for the array.
I've found the problem. CornedBee is right, the pair of my coordinate(x,y) is out of bounds. At first, I thought it was the problem with the if statement.
Thanks.