Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all,
Vanilla are planning an update to the site on April 24th (next Wednesday). It is a major PHP8 update which is expected to boost performance across the site. The site will be down from 7pm and it is expected to take about an hour to complete. We appreciate your patience during the update.
Thanks all.

Quick Java Question

  • 23-08-2007 5:19pm
    #1
    Closed Accounts Posts: 1,080 ✭✭✭


    I have an exam tomorrow and I cant for the life of me remember what '==' means I know that && is and, || is or but what is '==' and what is +=


    Also ++ is to count down and -- is to count up but can you have +-?


Comments

  • Registered Users Posts: 4,359 ✭✭✭jon1981




  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    ++ increments so

    int i = 1;
    i++;

    means that i now equals 2.

    -- decrements so
    int i = 2;
    i--;
    means that i now equals 1.

    no you can't have +-.

    Good luck in your exam.


  • Registered Users Posts: 11,262 ✭✭✭✭jester77


    "==" is for comparing values, "=" is for assinging values,

    eg..
    int i = 2; // means that i now has the value 2
    
    if (i == 1) // returns boolean value false as i = 2 and won't go into the if statement
    {
    }
    


  • Registered Users Posts: 26,556 ✭✭✭✭Creamy Goodness


    Evil Phil wrote:
    no you can have +-.
    not much of a java person - more C/C++ - but is that a typo?

    should that be "no you can't have +-"?


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    Oops, fixed.


  • Advertisement
  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,082 Mod ✭✭✭✭Tar.Aldarion


    It was a typo yeah

    edit: oops, should have refreshed!


  • Registered Users Posts: 26,556 ✭✭✭✭Creamy Goodness


    Evil Phil wrote:
    Oops, fixed.
    heheh was just thinking i missed this magical operator that incremented by one whilst decrementing by one at the same time :D


  • Closed Accounts Posts: 583 ✭✭✭monkey tennis


    eamoss wrote:
    but can you have +-?

    No, but there's a little known workaround that most people never even think of:

    i = i;

    This little doozy has saved me a lot of headscratching!
    Make sure you mention it in the exam.


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    :)

    Now now folks, don't be given misleading information. /looks at monkey tennis

    We were all newbies at some point, somewhat better prepared for our exams perhaps, but newbies all the same.


  • Closed Accounts Posts: 1,106 ✭✭✭MoominPapa


    &&:ampersAND
    ||: pipeOR
    ==:equalsequals
    !:NOTonyournelly
    Simple, now you'll never forget - although you've probable already sat you exam and if you failed because you didn't know basic logic operators then this will curse you for the rest of your days, unless you repeat and pass, either way BOL


  • Advertisement
  • Registered Users Posts: 11,977 ✭✭✭✭Giblet


    x = ++x;


Advertisement