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 trialNila Palmo Ram
4,303 PointsIt says my code took too long to run what should I do?
Can you please tell me if it is a syntax error or something to do with the server.
// I have initialized a java.io.Console for you. It is in a variable named console.
String response;
console.printf("Do you understand do while loops? ");
{
response = console.readLine ("Do you understand do while loops? ");
} while(response.equals("No"));
1 Answer
Jennifer Nordell
Treehouse TeacherHi there! It is not really a syntax error nor is it a problem with the server. This code will not produce a syntax error (it will compile without problem), but what you have here is what we call a runtime error. This is an error that occurs while the program is running but didn't cause a compiler error and it is generally a logic flaw. In this case, you left off the do
part of the do while
loop. You created an infinite loop inadvertently.
// I have initialized a java.io.Console for you. It is in a variable named console.
String response;
do { // do this
response = console.readLine ("Do you understand do while loops? "); // Set the response to the user's input
} while(response.equals("No")); // when the answer is NOT "No" exit the loop
Hope this helps, but let me know if you have any questions!
Nila Palmo Ram
4,303 PointsNila Palmo Ram
4,303 PointsThank you so much!!