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 trialLouis Mott
1,923 PointsJava Looping until the value passes
not sure why im getting error "Variable response may not have been initialized"
// I have initialized a java.io.Console for you. It is in a variable named console.
String response;
boolean isValidResponse;
do {
console.readLine("Do you understand do while loops? ");
isValidResponse = (response.equalsIgnoreCase("Yes"));
if (isValidResponse) {
console.printf("Great!");
}
} while (isValidResponse);
3 Answers
Florian Tönjes
Full Stack JavaScript Techdegree Graduate 50,856 PointsHey Louis,
you are reading a line from the console but are not assigning it to the variable 'response'.
try this:
response = console.readLine("Do you understand do while loops? ");
Kind Regards, Florian
Louis Mott
1,923 PointsPERFECT! thanks!
Anthony Parkes-Skelly
3,144 PointsWhere did you get the "yes" and if statement from?