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

Raquel Schmidt
Raquel Schmidt
402 Points

how to make a response outside of the do while loop.

having trouble

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


}while 

1 Answer

Hi Raquel,

I was able to go into the Code Challenge that you were on and figure out what was happening.

First, when you are declaring the two Strings question and response, you actually have one variable too many. What you need to do hear is to take the line you have for the variable question and just rename that response, but leave everything else.

Then we you set up your do...while loop, you just past that same response variable line in between the curly braces (except without the String declaration this time).

The while part of the do...while loop is where your condition goes. The syntax is while( some conditional statement ) if it is true, then the code between the braces runs again, if it is false the do...while loop ends.