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

Java

not sure what I have wrong here, help?

My task is: "Add another if statement that checks if the firstExample is equal ignoring case to thirdExample. If it, is print out "first and third are the same ignoring case". "

I have:

if (firstExample.equalsIgnoringCase (thirdExample)); { 
   console.printf "(first and third are the same ignoring case"); 
}

It seems right to me since I did the last one which was the same concept. Could this be a glitch or am I missing something small?

4 Answers

Hi Greatest

I think your issue here may be the semi-colon immediately after the if statement's closing brace and I've noticed you're missing the opening brace on your printf method too.

EDIT: We also noticed that the string method wasn't quite right so this post has been updated to also reflect that change.

So I think it should be:

if (firstExample.equalsIgnoreCase(thirdExample)) { 
   console.printf("first and third are the same ignoring case"); 
}

Hope it helps but if not let me know and I'll take a closer look.

Stephen

Thanks for the fast reply! But I am still getting an error after messing with the semicolon. Also I just realized that when I was typing up the question I missed that brace but in my actual statement I have it there. Just edited it sorry about that

No problem. Can you tell me which exercise/task this relates to so I can quickly fire it up?

Also if you're able to post the error it may help point us in the right direction.

OK so I pasted your original code into the challenge and the issues were with the semi-colon at the end of the if statement conditional (the bit in the braces) and the missing opening brace from the printf method as we discussed earlier.

The bit I didn't pick up on was that the string method is actually equalsIgnoreCase not equalsIgnoringCase. Once I changed that it passed the test.

Here's the code below:

if (firstExample.equalsIgnoreCase(thirdExample)) { 
   console.printf("first and third are the same ignoring case"); 
}

Hope it helps!

Stephen

That helped thank you very much. I was copying the wording in the question so that didnt even occur to me haha

Yeah! When I looked at it initially I did the same thing :)

if (firstExample.equalsIgnoreCase(thirdExample)) { console.printf("first and third are the same ignoring case"); }

I typed exactly same with you but i still got bummer. Dont know why it did not work

Android development stage 3 perfecting the prototype string equity http://teamtreehouse.com/library/java-basics/perfecting-the-prototype/string-equality

JavaTester.java:83: error: cannot find symbol if (firstExample.equalsIgnoringCase (thirdExample)); { ^ symbol: method equalsIgnoringCase(String) location: variable firstExample of type String 1 error

String firstExample = "hello"; String secondExample = "hello"; String thirdExample = "HELLO";

if (firstExample.equalsIgnoreCase(thirdExample)) { console.printf("first and third are the same ignoring case"); }

Am getting error, what am I doing wrong.