Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: If Statement

  1. #1
    Junior Member
    Join Date
    Mar 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default If Statement

    Hello, Pls what is the output of X in this fragment of code?
    if(x >15)
    System.out,println("A")
    else if(x <20)
    System.out,println("B")
    else
    System.out,println("C")


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: If Statement

    what is the output of X
    That code does not define a value for the variable x and does not print it.

    If that code comes from a larger program, what happens when you compile and execute the code?
    Add a println() statement just before the first if that prints out the value of x so you can see what it is.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. if statement help
    By Kez in forum What's Wrong With My Code?
    Replies: 5
    Last Post: January 15th, 2014, 10:54 AM
  2. Replies: 2
    Last Post: June 25th, 2013, 06:33 AM
  3. [SOLVED] A Loop statement and a switch statement issue
    By sternfox in forum Loops & Control Statements
    Replies: 13
    Last Post: March 7th, 2013, 04:19 PM
  4. Replacing an If statement with a Switch statement
    By logi in forum Loops & Control Statements
    Replies: 9
    Last Post: February 4th, 2013, 12:21 AM
  5. If-Else Statement help
    By SnowCrashed in forum Loops & Control Statements
    Replies: 5
    Last Post: February 9th, 2010, 07:57 PM