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

Don't Understand First Part of Challenge

I don't understand how to write the equals portion to actually compare the firstExample and secondExample.

I originally got past the first part of the challenge with if (firstExample.equals("hello")); but I don't see how that piece of code actually compares both values.

2 Answers

Hi Remington,

Instead of passing in the string "hello" you can pass in the variable secondExample

if (firstExample.equals(secondExample))

This will check if the 2 variables are equal,

The code you posted is checking if firstExample is equal to the string "hello" without taking into consideration the second variable.

Dylan Merritt
Dylan Merritt
15,682 Points

Can you please post the exact question from the challenge you are referring to?