Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2011
    Posts
    5
    Rep Power
    0

    Default 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)


    Java Code:
    private boolean isExit(int i, int j) 
          {
             if (((i = 0) || (i = width - 1))||((j = 0) || (j = height - 1))) return true;
             return false;
          }
    However it says the or operator "||" can't be applied to int, int.
    This line, same except with </> instead of = works fine though:
    Java Code:
    if (((i < 0) || (i > width - 1))||((j < 0) || (j > height - 1))) return false;
    Help!
    Thanks


    DOH only typed one equals in code. Derp.

    Sorry!
    Last edited by rockgardenlove; 02-10-2011 at 03:27 AM.

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,784
    Rep Power
    7

    Default

    Java Code:
    i = 0
    That is an assignment and not a comparison statement.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    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.

  4. #4
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,784
    Rep Power
    7

Similar Threads

  1. Sum of odd ints 0-n
    By falkon114 in forum New To Java
    Replies: 7
    Last Post: 12-06-2010, 08:36 AM
  2. Help with ints
    By Insomniac Riot in forum New To Java
    Replies: 5
    Last Post: 04-02-2010, 03:53 PM
  3. checking for ints in a String
    By SteroidalPsycho in forum New To Java
    Replies: 1
    Last Post: 03-26-2010, 06:09 PM
  4. GUI's and inputting doubles or ints
    By lopder1 in forum New To Java
    Replies: 19
    Last Post: 11-05-2009, 08:50 PM
  5. reading in unsigned ints into a 2D array
    By newToIt in forum New To Java
    Replies: 9
    Last Post: 03-06-2009, 12:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •