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

Hey, I really dont know how i should do this. I need some help to get an impression how i have to start on this.

I dont really know, what i need to do. Thank you, for heling me out.

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

1 Answer

You can ditch the first two variables (abc & noun). You'll want to switch the noun variable name in you do-while to response. Then you'll want to add the while portion at the end of the do {}.

Example:

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

That way the user can be prompted "Do you understand do while loops? " and their response will be read into the 'response' variable. which can then be checked in the 'while' comparison argument. If the user responds "no" the DO portion will execute again.

Let me know if you have questions!