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 trialDavid Moro
849 PointsError
Im getting this error, how do i fix this?
TreeStory.java:27: error: cannot find symbol
isInvalidWord = (noun.equalsIgnoreCase("dork") ||
^
symbol: variable isInvalidWord
location: class TreeStory
1 error
2 Answers
Kourosh Raeen
23,733 PointsHave you defined the variable isInvalidWord before using it? You should have the line:
boolean isInvalidWord;
Stephen Emery
14,384 PointsBefore to do loop you need to define the boolean. That way the program knows the variable inside and outside the loop. If you put it directly in the loop, the outside code can't "see" it. Try this:
boolean isInvalidWord; do { noun = console.readLine("Enter a noun: "); isInvalidWord = (noun.equalsIgnoreCase("dork") || noun.equalsIgnoreCase("jerk")); if (isInvalidWord) { console.printf("That is unacceptable language :( Please try again.\n"); } } while(isInvalidWord);
Stephen Emery
14,384 PointsSorry the comment box did not keep my code tabs and separations. Look for the ";" to see the breaks.