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 trialJuan Sebastian Ortiz
761 PointsChallenge Task 2 of 3. Java Basics
I keep trying to change my code but it keeps giving me the same error. it's 'boolean cannot be converted to String error'
Thanks for your help.
Juan Ortiz
// I have initialized a java.io.Console for you. It is in a variable named console.
String response = console.readLine("Do you understand do while loops");
boolean badResponse;
do {
response = (response.equalsIgnoreCase("No"));
} while (badResponse);
1 Answer
Raffael Dettling
32,999 PointsYou donΒ΄t need the boolean variable also the task was to ask till the answer is something diffrent then "no" so you have to use the readline inside the do while loop. Then you can test with equalsIgnoreCase if the response is no or not.
String response;
do {
response = console.readLine("Do you understand do while loops? ");
} while(response.equalsIgnoreCase("no"));