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

Example.java
// I have initialized a java.io.Console 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?");
    responseNo.equalsIgnoreCase("No");

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

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

1 Answer

Steven Parker
Steven Parker
171,327 Points

You have a syntax error on this line:

    responseNo.equalsIgnoreCase("No");

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);