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 trialWilliam Lowther
1,281 PointsGetting an error I can't figure out.
In the following block of code:
boolean isInvalidWord;
do {
noun = console.readLine("Enter a noun: ");
isInvalidWord(noun.equalsIgnoreCase("dork") ||
noun.equalsIgnoreCase("jerk") ||
noun.equalsIgnoreCase("nerd"));
if (isInvalidWord){
console.printf("That language is not allowed. Try again. \n\n");
}
}while (isInvalidWord);
I am getting the following error:
TreeStory.java:27: error: cannot find symbol
isInvalidWord(noun.equalsIgnoreCase("dork") ||
^
symbol: method isInvalidWord(boolean)
location: class TreeStory
1 error
I'm not sure where it is coming from, and I'm not seeing a difference in my use of the boolean and the one given in the example video. Any help would be appreciated.
2 Answers
Richard Ling
8,522 PointsHi William,
You're very close with the answer here. I amended it slightly to:
boolean isInvalidWord;
do {
String noun = console.readLine("Enter a noun: ");
isInvalidWord = (noun.equalsIgnoreCase("dork") ||
noun.equalsIgnoreCase("jerk") ||
noun.equalsIgnoreCase("nerd"));
if (isInvalidWord){
console.printf("That language is not allowed. Try again. \n\n");
}
}while (isInvalidWord);
Only 2 things, firstly the variable noun wasn't declared, so I just added String to the front. Secondly, isInvalidWord needed an equals sign after it. In your code, it is being used like a method. It actually needs to be assigned the result from the censored words checks within the brackets.
Hope that helps :)
William Lowther
1,281 PointsThank you! The noun was declared above boolean, I probably should have included that in my code snippet. I don't know how I missed that = sign though. I appreciate the help!