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 trial
Michael Duncan
809 PointsTrying to complete a string contains which ignores case but getting an error. Umsure where I am going wrong
String noun; boolean isInvalidWord;
do {
// Ignoring case if statement
noun = console.readLine("Enter noun: ");
isInvalidWord = (noun.equalsIgnoreCase("dork") ||
noun.equalsIgnoreCase("jerk") ||
noun.equalsIgnoreCase("nerd") ||
noun.containsIgnoreCase("poo"));
if (isInvalidWord) {
console.printf("That langauge is not allowed. Try again \n \n");
}
} while(isInvalidWord);
Getting the below error:
TreeStory.java:34: error: cannot find symbol
noun.containsIgnoreCase("poo"));
^
symbol: method containsIgnoreCase(String)
location: variable noun of type String
1 Answer
markmneimneh
14,133 PointsHello
the error your seeing is because you are doing this:
noun.containsIgnoreCase("poo"));
The Java String library does not contain this moths ... it has a equalsIgnoreCase method, but not containsIgnoreCase
take a look here
https://docs.oracle.com/javase/8/docs/api/java/lang/String.html
I suspect it just a typo and you meant equalsIgnoreCase
If this answers your question, please Mark the question as answered.
Thanks