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 trialBenjamin Cha
2,761 PointsHow to fix this prompt-related project?
I must get this program to work, but there's one compile error that's causing it to malfunction. What way should I fix this...
// I have initialized a java.io.Console for you. It is in a variable named console.
String response;
boolean isNotUnderstanding;
do{
response = console.readLine("Do you understand do while loops? ");
booleanisNotUnderstanding = (response.equalsIgnoreCase("no"));
if (isNotUnderstanding){
console.printf("...");
}
} while(isNotUnderstanding);
1 Answer
Steven Parker
231,271 PointsThe result suggests that you use the "preview" button to see the errors. When you do, you get this:
JavaTester.java:123: error: cannot find symbol
booleanisNotUnderstanding = (response.equalsIgnoreCase("no"));
^
symbol: variable booleanisNotUnderstanding
location: class JavaTester
1 error
This refers to the variable on line 5 of the code, which on line 2 was declared with the name "isNotUnderstanding". The type of variable is indeed "boolean", but that keyword is not part of the name.
Changing the name on line 5 to "isNotUnderstanding" will remove the compile error.
Benjamin Cha
2,761 PointsBenjamin Cha
2,761 PointsThanks! I didn't know that there was an error on the 5th line, but I saw that I accidentally added "boolean" on to the isNotUnderstanding variable and deleted it. It worked after fixing it! :)
Thank you!