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

Totally clueless on task 2 of 3 for perfecting prototypes.

Hi there,

I am supposed to continually prompt the user on the question "do you understand do while loops", as long as they say no. I am totally stuck on how to continually prompt them using do while loops. Could you give me some help please? Thanks!

Example.java
// I have initialized a java.io.Console for you. It is in a variable named console.
String response;
boolean isInvalidWord;
do {
response = console.readLine("Do you understand do while loops?");
isInvalidWord = (response.equalIgnoreCase("no"));
  while(isInvalidWord) }

I think that you forgot the period in between equal and ignorecase!

1 Answer

There is no need to initialize a new variable called isInvalidWord. Just use the equalsIgnoreCase mathod on the response variable like so:

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