Results 1 to 6 of 6
  1. #1
    jigglywiggly is offline Senior Member
    Join Date
    Nov 2008
    Posts
    105
    Rep Power
    0

    Default [SOLVED] How to write and or?

    Say you have something like this

    if(nums[2][1]==1 && nums[2][2]==1 && nums[2][3]==1) {
    b= true;
    }

    How could you say if nums[2][1]==1||-1 &&nums[2][2]==1 || -1 && nums[2][3]==1||-1 ?

    It will complain about cannot compare int,boolean. Is this possible? Because I want it to check if it's -1 or 1

  2. #2
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    Java Code:
    if( (nums[2][1] == 1 || nums[2][1] == -1) &&
    ...

  3. #3
    jigglywiggly is offline Senior Member
    Join Date
    Nov 2008
    Posts
    105
    Rep Power
    0

    Default

    Oh yeah that makes a lot of sense, why didn't I think of that :)
    Thanks dude.

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Have to compare in each cases.

    If you have solve the problem please mark the thread solved. :)

  5. #5
    jigglywiggly is offline Senior Member
    Join Date
    Nov 2008
    Posts
    105
    Rep Power
    0

    Default

    How do I mark it as solved?

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. What are you using to write your code?
    By CaptainMorgan in forum New To Java
    Replies: 990
    Last Post: Yesterday, 03:28 AM
  2. Problem with what to write in URL
    By Manoeuvre in forum Eclipse
    Replies: 0
    Last Post: 12-01-2008, 02:56 PM
  3. How to write....**
    By krichait in forum New To Java
    Replies: 9
    Last Post: 08-07-2008, 02:09 PM
  4. Could some plz tell me how to write a stand alone
    By quickfingers in forum New To Java
    Replies: 25
    Last Post: 06-28-2008, 04:22 AM
  5. Write to file
    By esadeghi in forum Advanced Java
    Replies: 1
    Last Post: 05-21-2008, 01:13 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
  •