The code shown would (suprisingly) print "Boo!". 🐞

See next.
Rectangle rec1, rec2;
rec1 = new Rectangle(10, 5);
rec2 = new Rectangle(10, 5);
if (rec1 == rec2)
	prn("Yay!");
else
	prn("Boo!");
For objects we want to use "equals" as shown.

The code shown would print "Yay!" (this assumes that 'equals' is properly implemented on Rectangle).
Rectangle rec1, rec2;
rec1 = new Rectangle(10, 5);
rec2 = new Rectangle(10, 5);
if (rec1.equals(rec2))
	prn("Yay!");
else
	prn("Boo!");
This will print "Yay!" (try it).

Only primitive (tiny) values use '==' for equality. Types including "int", "boolean" and "double".

Note that String is a full-fledged object type (i.e. use "equals" not "==").

Confusing eh? See next.
int a, b;
a = 10;
b = 10;
if (a == b)
	prn("Yay!");
else
	prn("Boo!");
If not sure which to use, we might first try "equals".

The compiler should give us a clear message if we are dealing with a primitive (that does not support "equals"). Then we could flip to "==".
int a, b;
if (z.equals(y))
	prn("Yay!");
else
	prn("Boo!");