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

Carlos Salcedo
Carlos Salcedo
1,788 Points

i cant seem to find where i am missing somthing?

i think i have it right so far there might be something missing that i havent seen

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(thirdExample)){
  console.printf("first and third are the same ignoring case");
  System.exit(0);
}

2 Answers

andren
andren
28,558 Points

In addition to removing System.exit(0); as Alexander Davison pointed out, you have to make sure to keep the code from the previous task intact. In these challenges you are not meant to remove or modify the code from the previous task when you work on the next task, all of the code has to be kept to complete the challenge.

It is a very common mistake in this task to modify the code from task 1 to complete task 2 instead of adding new code. And it looks like you have done just that. If you add back the code that you wrote in part 1 like this:

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

if(firstExample.equals(secondExample)){
  console.printf("first is equal to second");
}

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

Then your code will pass.

Carlos Salcedo
Carlos Salcedo
1,788 Points

of course i had to leave the other part of the code. beginners mistake, thanks alot

You should remove the line of code that says System.exit(0); . The challenge didn't ask for that.

I hope this helps. ~Alex

If this answered your question, please mark it as a Best Answer. Thank you!

Carlos Salcedo
Carlos Salcedo
1,788 Points

i did that and it says : Bummer! Make sure you are using equalsIgnoreCase on the firstExample variable and use console.printf i think that is was is shown in the code?