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

2. The Class Point


A 2D geometrical point gives a location using two values, usually an x value and a y value.

The Class Point


Think of a two dimensional point as an object that consists of two values, the distance x from the origin along a horizontal axis, and the distance y from the origin along a vertical axis. In Java graphics, the upper left corner of a drawing area (such as a window) is considered to be the origin (0, 0), so y increases going downward.

It is convenient to think of a point as a single thing (not as two separate things). For example, you think of the end point of a line as one thing. And you think of the corner of a square as one thing. This is an example of abstraction. In Java, an abstraction usually calls for a class.

Java comes with a package of predefined classes that are used for building graphical user interfaces, the Application Windowing Toolkit, or the AWT. One of the many classes in the AWT is the class Point.

The class Point describes two things: the variables (the data) and the methods (the behavior) of Point objects.

Question 2:

What two variables do you expect a Point object to have?

Click here for a