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

Derek Williams
Derek Williams
522 Points

I believe I am doing this right by using... if (firstExample.equals(secondExample)) { ... but it is saying try again.

I feel I am doing this right but it keeps telling me to try again. Maybe I am missing a character somewhere but I have checked to see. It's not showing a compiler error but just telling me to try again.

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.equals(secondExample)) {
  console.printf("first is equal to second");
  System.exit(0);
}

No need to include "System.exit(0)"

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hi Derek,

You do have the correct code, but you also have code that the challenge did not ask for. If you just delete the extra line of code System.exit(0);, the task will pass.

Note to Remember: Challenges are very strict and instruction need to be followed explicitly. A very good rule to follow: If the instructions don't ask you to do something... don't.

Nice work! :) :dizzy: