Java Java Basics Perfecting the Prototype Looping until the value passes

Haydn Hurst
Haydn Hurst
2,358 Points

I am stuck on step two of this task; I cannot figure out how to make the do/while loop work.

The part of the loop I can't get is the while part. It gives me an error about not getting strings to booleans, but I don't know how to convert it properly, or even if that is the correct way to go.

Example.java
// I have initialized a java.io.Console for you. It is in a variable named console.

String response;

do
{
response = console.readLine("Do you understand do while loops?");
}while (response = "no");

1 Answer

KRIS NIKOLAISEN
KRIS NIKOLAISEN
54,375 Points

You should be using a comparison operator instead of the assignment operator:

while (response == "No")

Note: I also changed the case of the N in no since that is what the task asks for.

Haydn Hurst
Haydn Hurst
2,358 Points

I don't know why I didn't think of that! Thank you so much!