## 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().

### 23. Practice

Answer:Does pointA.equals(pointB) return the same true/false value as pointB.equals(pointA) ?Yes.Does pointA == pointB return the same true/false value as pointB == pointA ?Yes.

# Practice

Perhaps you would like to practice? Assume that each row is independent of the others.

code sectionpointA == pointBpointA.equals( pointB )
Point pointA = new Point( 0, 0 );
Point pointB = new Point( 0, 0 );

Point pointA = new Point( 21, 17 );
Point pointB = pointA;

Point pointA = new Point( 21, 17 );
Point pointB = new Point( 7*3, 20-3 );

Point pointA = new Point( 21, 17 );
Point pointB = new Point( pointA );

Point pointA = new Point( 21, 17 );
Point pointB = new Point( 21, 17 );
pointA.move( 8, 12 );

Point pointA = new Point( 21, 17 );
Point pointB = pointA;
pointB.move( 8, 12 );


Notice that in the last question there is only one object, with two variables pointing to it. When the move() operation is performed, the data in that one object is changed. So it is still true that the data referred to by one reference variable is the same as that referred to by the the other. So equals() still reports true.

With aliases it is easy to get confused and think that there are two objects when in fact there is only one. Perhaps this is why bank robbers use aliases.

Question 23:Could an object have more than two aliases?