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 there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Quick Java Question

  • 23-08-2007 4: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, Registered Users 2 Posts: 4,359 ✭✭✭jon1981




  • Registered Users, Registered Users 2 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, Registered Users 2 Posts: 11,264 ✭✭✭✭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, Registered Users 2 Posts: 26,584 ✭✭✭✭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, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    Oops, fixed.


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


    It was a typo yeah

    edit: oops, should have refreshed!


  • Registered Users, Registered Users 2 Posts: 26,584 ✭✭✭✭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, Registered Users 2 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, Registered Users 2 Posts: 11,989 ✭✭✭✭Giblet


    x = ++x;


Advertisement