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 trialFin Muir
1,108 PointsI'm not sure of how to do do loops. I was following the video and I missed something now my workspace ruined.
I was following the video when I must of missed something. I tried to fix it myself but buried me into a deeper hole
// 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? ");
boolean isInvalidWord = (response.equalsIgnoreCase("no"));
boolean isInvalidWord;
do {
if (isInvalidWord) {
System.exit(0);
}
};
1 Answer
Connor Walker
17,985 PointsThe problem with your loop is you are missing your loop conditions so it doesn't know when to loop through the code. A do while loop should look something like this:
do {
//code to be repeated
} while (conditions);
So in the case of this challenge, that would look like this:
// 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? ");
do {
response = console.readLine("Do you understand do while loops? ");
} while (response == "No");