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.

Geovani Estacio
Courses Plus Student 1,875 PointsCan anyone help me with equality's, I am stuck on this one. What am i missing here.
String firstExample = "hello"; if (firstExample.equals("secondExample") ) { console.printf("first is equal to second"); System.exit(0); } String secondExample = "hello"; String thirdExample = "HELLO";
// I have imported a java.io.Console for you, it is named console.
String firstExample = "hello";
if (firstExample.equals("secondExample") ) {
console.printf("first is equal to second");
System.exit(0);
}
String secondExample = "hello";
String thirdExample = "HELLO";
2 Answers

Jonathan Grieve
Treehouse Moderator 91,028 PointsThere's a couple of things to try here.
First of all, you're passing in a String to the equals() method rather than a reference to secondExample
.
Also, try storing all your variables above anything else in your code, so the method knows what the variables are, what they contain and what to do with them. :-)

Digvijay Katoch
1,637 PointsMake it
firstExample.equals(secondExample)
When you place something in double quotes, it becomes a string literal and that is what gets compared. You were trying to compare "hello" to "secondExample". You should be comparing "hello" to "hello". or firstExample to secondExample.
Also, create variables above the if statement.

Geovani Estacio
Courses Plus Student 1,875 PointsThank you Digvijay Katoch!
Geovani Estacio
Courses Plus Student 1,875 PointsGeovani Estacio
Courses Plus Student 1,875 PointsThank you Jonathan!