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 Objects (Retired) Meet Objects Welcome Back

use of boolean operator "=="

how to use "==" operator in java-repl for compareing two no a == b; is giving illeagal start of expression

Grigorij Schleifer
Grigorij Schleifer
10,365 Points

HI aditya,

How are you going with the boolean operator problem ? Do you need more explanation?

Could you mark my answer as best, if it was helpful so other Java-Fighters could see it.

Grigorij

1 Answer

Grigorij Schleifer
Grigorij Schleifer
10,365 Points

Hi aditya,

have you declared a and b before comparing them ?

If you code:

java-repl
java> String a = "a";
java.lang.String a = "a"

java> String b = "a";
java.lang.String b = "a"

java> boolean equal = a==b;
boolean equal = true

This should work fine

Grigorij