Java Java Basics Perfecting the Prototype Looping until the value passes

radha kumar
radha kumar
526 Points

not sure what im doing wrong

I just really dont understand where i am going wrong
// I have initialized a for you. It is in a variable named console.

String response; //define variable outside of loop
boolean responseNo;
do {
  response = console.readLine("Do you understand while loops?");

    if (responseNo)
      console.printf("Learn again");

while (responseNo.equalsIgnoreCase("No"));

1 Answer

Steven Parker
Steven Parker
179,718 Points

You have a syntax error on this line:


What you probably intended to do was to assign the boolean using the result of the comparison:

    responseNo = response.equalsIgnoreCase("No");

And then in the "while" you only need the boolean:

while (responseNo);