Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1113917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:55:41+00:00 2026-05-17T02:55:41+00:00

Ok so lets say I have boolean x = false . If I have

  • 0

Ok so lets say I have boolean x = false. If I have a loop that says while (!x) does this mean while x is NOT false (true) or while x is NOT true (false)?

EDIT:
Ok I’m a bit confused, I think Im getting different answers. So if I have

 int x=0;
 boolean add1=false;
 while (!add1){
        x=1;
}

What is the final value of x in this case?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T02:55:42+00:00Added an answer on May 17, 2026 at 2:55 am
    x=false;
    while (!x)
    

    substituting the value of x we have

    while(!false)
    

    Now ! is the logical complement operator which inverts the value of a boolean so we get

    while(true)  
    

    So we keep looping till x is false or till !x is true.

    Note that the value of the variable can change in the body of the loop causing the looping to break. Consider a typical search program which uses a boolean variable called found:

    found = false;  // initialize found to false.
    while(!found) { // keep looping till key is not found.
      ...
      if(key is found) {
        found = true; // key found...make found true. 
      }
    }
    

    UPDATE:

    In your updated question add1 is false initially so !add1 is true so we enter the while loop and change x to 1. Since the value of add1 does not change in the loop and there are no break and return you keep looping infinitely.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say i have a thread running like this: private boolean working = true;
I have a boolean property in my ViewModel, named lets say IsNotSupported that is
Lets say I have a class A that is fairly simple like this -
Lets say I have an object with two boolean properties: public bool AdvancedMode{ get;
Lets say have this immutable record type: public class Record { public Record(int x,
Lets Say i have a table like this WEB_LIST_TABLE KEY Value ---------------------------------------- 134 google.com
Let's say for example, I have the following javascript function that returns a boolean:
I have two objects that are derived from same the base class. Lets say
Lets say we have a table here, populated with the following data: acc_id1 acc_id2
Lets say I have five tables named table1, table2 ... table5. I have already

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.