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

15. Review


Exactly the same as the first version of it:

    java.awt.Point[x=12,y=45] java.awt.Point[x=-13,y=49]

You can not be sure about the internal workings of a program by inspecting its output!


You might want to review the two programs to be sure that you understand their differences:

Program:What it did:
object, method changes state The first programAn object was constructed. The variable pt refers it.
Then, new data replaced the old data inside the same object.
object, assignment replaces old The second programAn object was constructed. The variable pt refers it.
Then, a new object was constructed with new data, and pt was changed
to refer to the new object. The first object became garbage.

Question 15:

When are two points equivalent?