Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By pbrockway2

Thread: � In java?

  1. #1
    Aimforthehead is offline Member
    Join Date
    Sep 2011
    Posts
    45
    Rep Power
    0

    Default � In java?

    I tried looking it up and all I could find is that ? was a substitute for "If-else" which doesn't look like it would apply here...
    The question is "what is the value inside the value variable at the end of the code snippet?"

    int value = 3;
    value = value � 2 * value;
    value++;

    Any hints?

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: � In java?

    What is �?

    In any case, it is not a valid Java operator. So the snippet can't appear as part of a valid Java program. And the question of the value of value does not arise.

    -----

    In general - and after you have sorted out what the code really is - you can find the value of a variable by using System.out.println(). Of course, finding the value leads to the more interesting question of why the variable has the value that you find it has. For that, read textbooks or internet sources. (Oracle's Tutorial is good - if only because most here have read the relevent bits) I can assure you that there is more (and better!) to be found than "is a substitute for if-else".

    If you get stuck: post code that compiles and runs, say (rather than ask) what the behaviour is, and quote or link to explanations that you want to ask about.
    Fubarable likes this.

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

    Default Re: � In java?

    Quote Originally Posted by Aimforthehead View Post
    all I could find is that ? was a substitute for "If-else"
    This suggests that they are talking about the ternary operator but the code certainly doesn't match.

  4. #4
    Aimforthehead is offline Member
    Join Date
    Sep 2011
    Posts
    45
    Rep Power
    0

    Default Re: � In java?

    Solved.
    The issue was my browser (mozilla) was not recognizing a minus sign (-) and replaced it with the strange question mark instead.

Posting Permissions

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