|
-
Nov 5th, 2006, 10:41 PM
#1
Thread Starter
Lively Member
if statement
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!
-
Nov 5th, 2006, 11:37 PM
#2
Addicted Member
Re: if statement
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?
-
Nov 5th, 2006, 11:55 PM
#3
Thread Starter
Lively Member
Re: if statement
I tried to run the program and it gives me an error "ArrayIndexOutOfBoundsException -1".
-
Nov 6th, 2006, 12:01 AM
#4
Addicted Member
Re: if statement
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.
-
Nov 6th, 2006, 03:43 AM
#5
Re: if statement
I wanted to say the array is greater than zero and equals to or less than 5.
You can't compare an array to a scalar. What your code does is:
"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.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 6th, 2006, 01:18 PM
#6
Lively Member
Re: if statement
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|