Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialC.J. Doyle
755 PointsSomeone please tell me what I'm doing wrong
I honestly don't see what I'm doing wrong. I researched this after the video, all is saying this is it but I don't see it
// I have initialized a java.io.Console for you. It is in a variable named console.
String response;
do {
console.readLine("Do you understand do while loops");
} while(response.equalsIgnoreCase("No"));
2 Answers
Jennifer Nordell
Treehouse TeacherHi there! You're super close on this one. And once I point out the flaw, it will likely become obvious. You have begun by setting the variable response
to an empty string. Then you read in an answer from the user. Then you compare the response
variable to "No". But here's the problem. With your current code, response will only ever be an empty string. It will never be equal to "No". This means that it will also never loop.
But why is this happening? You're reading in the data from the user. The problem is that you're not assigning what the user types in back into the response
variable.
Hint: Somewhere in your code you should see response =
and the thing on the right side should be what the user is typing in.
Hope this helps, but let me know if you're still stuck!
C.J. Doyle
755 PointsString response; do { response = console.readLine("Do you understand do while loops?"); } while(response.equalsIgnoreCase("No"));
do you mean like this? because this isn't working for me either
Jennifer Nordell
Treehouse TeacherYou posted a separate question regarding this, and the code you posted in that question differs from this code by one character. Take a close look at the last line.
If I take the code you posted above, and paste it in the challenge, it passes the first two steps. But the code in your other question will not pass as it introduces a syntax error.