Results 1 to 4 of 4
Thread: Boolean operators on ints
- 02-10-2011, 03:24 AM #1
Member
- Join Date
- Feb 2011
- Posts
- 5
- Rep Power
- 0
Boolean operators on ints
width and height are int values that indicate the size of the array (9 x 9) in this case.
i and j are the two indexs of the 2D array. What I am trying to do is figure out if point [i][j] is on the edge of the array.
That is, I want to check that:
(i is equal to 0 or width-1) and (j is equal to 0 or height-1)
However it says the or operator "||" can't be applied to int, int.Java Code:private boolean isExit(int i, int j) { if (((i = 0) || (i = width - 1))||((j = 0) || (j = height - 1))) return true; return false; }
This line, same except with </> instead of = works fine though:
Help!Java Code:if (((i < 0) || (i > width - 1))||((j < 0) || (j > height - 1))) return false;
Thanks
DOH only typed one equals in code. Derp.
Sorry!Last edited by rockgardenlove; 02-10-2011 at 03:27 AM.
- 02-10-2011, 04:09 AM #2
That is an assignment and not a comparison statement.Java Code:i = 0
-
I think that he figured this out, given his comments at the end. He should mark the thread as solved though so we can conserve brain power for where it's needed.
- 02-10-2011, 04:14 AM #4
Similar Threads
-
Sum of odd ints 0-n
By falkon114 in forum New To JavaReplies: 7Last Post: 12-06-2010, 08:36 AM -
Help with ints
By Insomniac Riot in forum New To JavaReplies: 5Last Post: 04-02-2010, 03:53 PM -
checking for ints in a String
By SteroidalPsycho in forum New To JavaReplies: 1Last Post: 03-26-2010, 06:09 PM -
GUI's and inputting doubles or ints
By lopder1 in forum New To JavaReplies: 19Last Post: 11-05-2009, 08:50 PM -
reading in unsigned ints into a 2D array
By newToIt in forum New To JavaReplies: 9Last Post: 03-06-2009, 12:36 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks