Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,704 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: