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 trialLex Dunko
Data Analysis Techdegree Student 4,449 PointsequalsIgnoreCase not working!
I cannot for the life of me find out where the fault is. It keeps telling me to make sure I am using the equalsIgnoreCase and the console.printf
All help appreciated - thanks in advance!
// I have imported a java.io.Console for you, it is named console.
String firstExample = "hello";
String secondExample = "hello";
String thirdExample = "HELLO";
if (firstExample == thirdExample){
console.printf("First and third are the same");
}
if (firstExample.equalsIgnoreCase (thirdExample)){
console.printf ("first and third are the same ignoring case");
}
1 Answer
Jason Anders
Treehouse Moderator 145,860 PointsHi Olexa,
Your code is pretty much correct, expect you have a space between the method name and the parenthesis for both methods. This is what is causing your error. Just remove the spaces and the rest looks good.
Nice work! :)
Lex Dunko
Data Analysis Techdegree Student 4,449 PointsLex Dunko
Data Analysis Techdegree Student 4,449 PointsHi Jason
Still doesn't seem to be working. I also updated my code to remove == and use .equals to see if that helped (it didn't).
// I have imported a java.io.Console for you, it is named console. String firstExample = "hello"; String secondExample = "hello"; String thirdExample = "HELLO"; if(firstExample.equals(thirdExample)){ console.printf("First and third are the same"); } if(firstExample.equalsIgnoreCase(thirdExample)){ console.printf("first and third are the same ignoring case"); }
Jason Anders
Treehouse Moderator 145,860 PointsJason Anders
Treehouse Moderator 145,860 PointsIt looks like you changed the code that was for the first Task? That code need to be left untouched. The first challenge is looking for a comparison of the first and second example with the string being printed: "first is equal to second". This will be the first
if statement
.The second task looks for the first and third ignoring case... this will be the second
if statement
and prints out "first and third are the same ignoring case". The firstif statement
should not be touched or changed for this task, but rather the second one just added under the first.Also, watch your capitalization for the strings. The instructions have all the strings lower case, but you have some capital letters. Challenges are very specific and instructions need to be followed exactly.
You have all the syntax correct , you just need to change the above to match what the instructions are asking for.
:)
Lex Dunko
Data Analysis Techdegree Student 4,449 PointsLex Dunko
Data Analysis Techdegree Student 4,449 PointsThanks. I ended up just resetting it and this time it worked. Not exactly sure where I went wrong and can't go back to compare - but it worked! Onward and upwards - thanks Jason!