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!

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 Looping until the value passes

Laura Chan
Laura Chan
997 Points

I don't understand what is wrong. Apparently 'Task one' is not passing anymore, but i don't understand why.

String reponse; do { String response = console.readLine("Do you understand do while loops?"); } while (response.equalsIgnoreCase("No"));

1 Answer

Joseph Wasden
Joseph Wasden
20,406 Points

You are declaring the type of the variable twice when you only need to when the field is initially declared. in other words, you don't need the String keyword to precede the response variable when you initialize its value. Also, you have spelling typo when you declare the variable. See the example below.

String response; //you were missing an 's' here

  do { 
    response = console.readLine("Do you understand do while loops?"); // notice the String keyword does not precede here
  } while (response.equalsIgnoreCase("No"));