Results 1 to 2 of 2
Like Tree1Likes
  • 1 Post By DarrylBurke

Thread: Another Array Issue (SOLVED)

  1. #1
    Captain Forge is offline Member
    Join Date
    Nov 2012
    Posts
    14
    Rep Power
    0

    Default Another Array Issue (SOLVED)

    Please disregard this post, I found my error. I did not know that in boolean statements (or whatever they're called) you use "==" instead of "=" for booleans. I knew you did that for int double etc., but I didn't know this was the case for booleans as well.
    Last edited by Captain Forge; 11-22-2012 at 05:22 AM. Reason: Solution solved

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,303
    Rep Power
    20

    Default Re: Another Array Issue (SOLVED)

    You practically never need to use == for boolean expressions. The == operator should never be used for comparing a boolean variable to a bolean literal (true or false). It's ok for comparing two boolean variables for the same boolean value (which can also be accomplished by using a combination of the ! (negation) and ^ (exor) operators).

    Note that these two tests are equivalent:
    Java Code:
    if (booleanVariable == true) {
      // do something
    }
    
    if (booleanVariable) {
      // do something
    }
    as are these:
    Java Code:
    if (booleanVariable == false) {
      // do something
    }
    
    if (!booleanVariable) {
      // do something
    }
    db
    Captain Forge likes this.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Out Of Memory Issue on Byte Array
    By arunkumar.palaniyappan in forum New To Java
    Replies: 1
    Last Post: 10-11-2012, 09:42 AM
  2. Array issue
    By daemonlies in forum New To Java
    Replies: 1
    Last Post: 04-30-2012, 12:23 AM
  3. Array game issue
    By Arom in forum New To Java
    Replies: 2
    Last Post: 11-30-2011, 08:33 PM
  4. Issue with setting values in an array
    By pyat77 in forum New To Java
    Replies: 4
    Last Post: 11-04-2011, 02:01 AM
  5. Sorting Array Issue
    By larson1118 in forum New To Java
    Replies: 2
    Last Post: 04-21-2011, 05:31 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
  •