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 trialShiva Lowy
Full Stack JavaScript Techdegree Student 3,240 PointsI am very confused and lost. I am not sure what I am doing wrong.
I am trying to do the loop code and it is not working for me. I tried to go back in the video and check but the code still is not working. Please help!! Thanks!!
// 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;
boolean response;
do {
response = console.readLine("No.");
4 Answers
Trent Christofferson
18,846 PointsFirst off String response is already initialized at the top, so creating another variable with the same name will give you an error. Second, for a do while loop it needs to be like so
do {
//code here will run at least once
} while (boolean condition)
the do loop will always run at least once and will keep running as long as the condition in the while is true.
namitha c
1,125 PointsString response = console.readLine("Do you understand do while loops?"); ");
do{ response = console.readLine("Do you understand do while loop?"); } while(response.equalsIgnoreCase("no"));
namitha c
1,125 Pointsplease remove the extra "); in the first line
Shiva Lowy
Full Stack JavaScript Techdegree Student 3,240 PointsThank you so much. I understand what I did wrong.