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

Chloe Leow
Chloe Leow
786 Points

Not sure what is wrong with String Equality Challenge Task 1

I got a lot of errors. How am I supposed to fix this?

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. \n");
  System.exit(0);

2 Answers

Brody Ricketts
Brody Ricketts
15,612 Points

Remove

System.exit(0);

That is not needed for this challenge. Take a look at your braces ({}), are you missing any?

When completing any Treehouse challenge, ensure that you follow the directions precisely as they are written. The instructions didn't ask for a new line to be created.

Remove

"\n"
Chloe Leow
Chloe Leow
786 Points

Thanks! It helped.

Bertan Ulusoy
Bertan Ulusoy
18,047 Points

Hi, your string equality check must not have quotation mark.

if (firstExample.equals(secondExample)) { ....

Chloe Leow
Chloe Leow
786 Points

Yeah, I did search on Google for that, but there are still lots of errors despite changing that.