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 trialRoy Nájar
192 PointsLoop
I´m stuck on this do while loop.
// 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?");
if(response.equalsIgnoreCase("Yes")){
}
while(response.equalsIgnoreCase("No"))
}
1 Answer
Jason Anello
Courses Plus Student 94,610 PointsHi Roy,
You have the syntax a little wrong.
The while
statement should come after the closing curly brace for the do-while loop and the while statement needs to end with a semicolon.
Also, you don't need the if condition to check if it's yes. You only need to loop and continually prompt if "No" is entered.
String response;
do {
response = console.readLine("Do you understand do while loops?");
} while(response.equalsIgnoreCase("No"));
Roy Nájar
192 PointsRoy Nájar
192 PointsThank you so much Jason.