How to use the equality operator in Java?
Equality operator is used to compare two similar things (numbers, characters, boolean, primitives and object references). Equality operator will always result in boolean value (true or false).
For object reference, it will return true if only both reference variables refer to the same object.
And here are the result of the program:
(kitty==kitten), the result is false
(kitty==sweetie), the result is true