Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

C.J. Doyle
755 Pointsdo I have to declare a boolean in order to do this is exercise?
The question does say I have to but do I indeed need to declare a boolean for this exercise?
// I have initialized a java.io.Console for you. It is in a variable named console.
console.readLine("Do you understand do while loops");
String response = ("Not Really? ");
do {
response = console.readLine("No");
}
} while response;
console.printf("I'm having a hard time");
2 Answers

Giovanni Esposito
7,818 PointsHi C.J. Doyle,
You'll need to use a boolean expression to the while stop condition. You can declare a boolean variable or doit directly on the conditional statement. For example:
Case a.-
console.writeLine("Do you understand do while loops"); String response = ("Not Really? "); boolean result = true; do { response = console.readLine("No"); result = ("No").equalsIgnoreCase(response); } while (result); console.printf("I'm having a hard time");
Case b.-
console.writeLine("Do you understand do while loops"); String response = ("Not Really? "); boolean result = true; do { response = console.readLine("No"); } while (("No").equalsIgnoreCase(response)); console.printf("I'm having a hard time");
I hope it is helpful. Remember vote for the answer

Antonio De Rose
20,882 PointsI will just give you a start up, just give it a try
String response = ""// you do it outside the loop, not to declare a variable all the time
do{
//code comes here, dont forget the semicolon
}while()//boolean condition, comes inside the brackets, dont forget the semicolon
C.J. Doyle
755 PointsC.J. Doyle
755 PointsThank you!