Java Java Basics Perfecting the Prototype Looping until the value passes

Andrew Minai
Andrew Minai
513 Points

Now continually prompt the user in a do while loop. The loop should continue running as long as the response is No.

I am unsure why my code is not working.
// I have initialized a for you. It is in a variable named console.
String response = "No";
    console.readLine("Do you understand do while loops?");
}while(response == false);

2 Answers

Priyajot Syan
Priyajot Syan
Pro Student 2,643 Points

While loop runs on the basis of the evaluation of the expression. What is your expression? Are you trying to compare String == boolean ? That doesn't work You have to do the right comparison in your while statement for it to run and stop Something like boolean response = false; so untill response is false loop will run and stop otherwise. And Also in case of do while the loop will always run atleast once irrespective of the fact whether expression evaluates to true or false