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 trial

Java Java Basics Perfecting the Prototype Censoring Words - Looping Until the Value Passes

java.lang.RuntimeException: Too many loops attempted! Check your while condition.

String response;

do {
    String question = console.readLine("Do you understand DO-while loops?");
    response = console.readLine("Please select an answer: ");                     
    if (response.equalsIgnoreCase("No")) {
      console.printf("Please try again");
      }
  } while(response.equalsIgnoreCase("No"));

so here is the code i wrote, what should i fix here?, thanks in advance.

1 Answer

Paolo Bass
Paolo Bass
3,921 Points

Hi Mohamed,

I think you have typed the wrong method in the second line of code:

String question = console.readLine("Do you understand DO-while loops?");

You are reading the line rather than printing the line. I'm not sure exactly what the method is to print to a console, however you can try this:

String question = console.printf("Do you understand Do-while loops?");

or

String question = console.writer.println("Do you understand Do-while loops?");

I hope this helped.