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 trialJason Scruggs
567 PointsCoding a do/while loop while declaring the string outside of the do/while loop.
I'm stuck on this question. I tried to copy what I saw in the video but I was unable to code it successfully. Thanks for your help.
// I have initialized a java.io.Console for you. It is in a variable named console.
String response = console.readLine("Do you understand do while loops?");
String response;
do {response = cnosole.readLine("Do you understand do while loops?");
if (response.equals("no"))
} while(response.equals("no"));
1 Answer
Steven Parker
231,269 PointsYou're close, you have the needed code but with some of the old code still left over.
- you don't need the first line anymore, one question in the loop is enough
- you also don't need the "if" line
- there's a spelling error where "cnosole" is written instead of "console"
- if this is for the challenge, it expects "No" (capital "N") instead of "no"
Jason Scruggs
567 PointsJason Scruggs
567 PointsThanks for your help!!