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 6 of 6

Thread: Java Question

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

    Default Java Question

    CONDITION 1: while ( !(cChoice == 'Q' || cChoice == 'q') )

    CONDITION 2: while ( cChoice != 'Q' || cChoice != 'q' )
    Last edited by senicamarcus; April 28th, 2014 at 08:15 PM. Reason: Learning something new


  2. #2
    Member
    Join Date
    Oct 2013
    Location
    Manila, Philippines
    Posts
    285
    My Mood
    Amused
    Thanks
    6
    Thanked 64 Times in 61 Posts

    Default Re: Java Question

    what is the question?

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

    Default Re: Java Question

    Do Conditions 1 and 2 give the same result? What tool or technique would you use to explain the result?

  4. #4
    Member
    Join Date
    Oct 2013
    Location
    Manila, Philippines
    Posts
    285
    My Mood
    Amused
    Thanks
    6
    Thanked 64 Times in 61 Posts

    Default Re: Java Question

    Quote Originally Posted by senicamarcus View Post
    Do Conditions 1 and 2 give the same result? What tool or technique would you use to explain the result?
    not always. It depend on the value of cChoice. I assumed that you have jdk installed in you computer and you know how to create a simple program, so you can try it on yourself. just print their values giving a different value in your cChoice.


    System.out.println(!(cChoice == 'Q' || cChoice == 'q'))
    System.out.println(cChoice != 'Q' || cChoice != 'q')

    but first, declare a value for your cChoice. after compiling and running it, try another value for cChoice. Then after that, you can draw a conclusion of your own.

  5. The Following User Says Thank You to dicdic For This Useful Post:

    senicamarcus (April 28th, 2014)

  6. #5
    Junior Member
    Join Date
    Apr 2014
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Java Question

    That's the same result i was getting...I wanted to make sure i was sane...

  7. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Java Question

    Look at De Morgan's law
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Java question
    By empms in forum Java Theory & Questions
    Replies: 0
    Last Post: September 30th, 2013, 04:05 PM
  2. Replies: 1
    Last Post: November 1st, 2012, 07:54 AM
  3. Challenging Java Question: Test your Java skill by grouping these terms
    By karthickk3 in forum Java Theory & Questions
    Replies: 3
    Last Post: July 18th, 2012, 10:10 PM
  4. help for this java question
    By marlontoyo in forum What's Wrong With My Code?
    Replies: 5
    Last Post: October 20th, 2011, 08:09 PM
  5. Java Question
    By NiCKYmcd in forum Java Theory & Questions
    Replies: 1
    Last Post: August 25th, 2010, 08:47 AM