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 trialBeverly Banks
1,919 PointsNot sure what I am doing wrong
Not sure what I am doing wrong...stuck on this challenge. Any help would be greatly appreciated! Thanks!
// I have initialized a java.io.Console for you. It is in a variable named console.
do {
String response = console.readLine("Do you understand do while loops?");
}while (response.equalsIgnoreCase)("no");
console.printf ("Try again!");
1 Answer
Jeremy Hill
29,567 PointsYou need to declare your String variable outside of the do while loop:
String response = "";
do{
response = console.readLine("Do you understand do while loops?");
}while(response.equalsIgnoreCase("No"));
Your compiler will throw a fit if it has to declare a variable each time through a loop. It only wants to declare it once.
Jeremy Hill
29,567 PointsJeremy Hill
29,567 PointsDon't forget to add your printf statement after the loop and the while condition.