go to previous page   go to home page   go to next page hear noise


A point consists of a pair of numbers, (x, y).

Description of a Class

The Java documentation describes the class Point. Look at the documentation on the web to see it. Point (Do a Google search for "Java Point" if the link fails). You will see something like the following:

The documentation shows the data and methods contained in Point objects, the constructors that create such objects, and their methods. Variables are sometimes called fields (as is done here). The two variables are named x and y and are of type int.

Class Point   

. . .

// Field Summary
int x; 
int y; 

// Constructor Summary
Point();                 // creates a point at (0,0)
Point(int  x, int  y);   // creates a point at (x,y)
Point( Point pt );       // creates a point at the location given in pt

// Method Summary
boolean equals(Object  obj);  // checks if two point objects hold equivalent data
void move(int  x, int  y);    // changes the (x,y) data of a point object 
String toString();            // returns character data that can be printed

(I've left out some methods we won't be using.)


There are three constructors listed for Point. Each one creates the same type of object. What is the difference between the constructors?

go to previous page   go to home page   go to next page