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 Java Basics Perfecting the Prototype String Equality

foxtails
foxtails
3,655 Points

Still trouble with first and third statement

Hi can anyone point out the mistake here?

Equality.java
// I have imported a java.io.Console for you, it is named console. 
String firstExample = "hello";
String secondExample = "hello";
String thirdExample = "HELLO";
if (firstExample.equalsIgnoreCase("HELLO")) {
  console.printf("first and third are the same ignoring case");
}

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

You've pretty much got it, except it looks like two things:

  1. First, it seems you deleted the first if statement from Task one. I'm not sure if this will cause a Bummer for the second task, but with challenges it usually does. Always add code for the next task and only delete or change previous code if explicitly told to do so in the instructions.

  2. Second, you are checking for a hard-coded value of "HELLO" instead of checking the variable. You should be comparing thirdExample not "HELLO". :)

Give it another go with those in mind. :dizzy:

foxtails
foxtails
3,655 Points

actually it worked with the first task the way I wrote it here, (sort of bug and sort of not because the values of first and second statement ARE the same). But I redid this again the way it should be written and I still get stuck. And it doesn't even give me idea, where the problem is in preview. Will paste the coding here: String firstExample = "hello"; String secondExample = "hello"; String thirdExample = "HELLO"; if (firstExample.equalsIgnoreCase(thirdExample)); { console.printf("first and third are the same ignoring case"); } Any ideas?

p.s. Just got it thanks to helpful pointout. It wasn't the code. I was replacing the code that should have stayed with new one. Awkward. Thank you for help