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 trialSara Brothers
7,341 PointsJava Basics Last Challenge
I need help please.
// I have initialized a java.io.Console for you. It is in a variable named console.
String response;
response = console.readLine("Do you understand do while loops? ");
String response;
do {
response = console.readLine("Enter no: ");
} while response;
Sara Brothers
7,341 PointsTo keep looping to response as long as no is typed. I think.
1 Answer
Mat Sanders
4,819 PointsOk without testing it first issue is the second reinitializing of the variable response.
Also your while loop is written wrong. Try something like this(did not test it)....
String response;
response = console.readLine("Do you understand do while loops? ");
while (!response.equals("no")){
response = console.readLine("Enter no: ");
}
Mat Sanders
4,819 PointsMat Sanders
4,819 PointsWhat is it wanting you to do?