More about Objects and Classes

The relational operations on primitive data are ==, >=, <=, >, <, and !=. They compare two data values, when those values' type has an ordering. For example, integers are ordered by size or magnitude. The result of a relational operation is a boolean value: either True or False. The relational operators on objects like Strings are different, and they are expressed as methods. Pay special attention to the equality method, equals().

20. alias-detector


Answer:

The two variables refer to the same object

alias-detector

aliasEg

The == operator looks only at variables. If two variables contain a reference to the same object, the operator evaluates to true.

Think of the == operator as an alias-detector.


Question 20:

(Thought question:) Could the equals() method be used with aliases?