Is it clear what the phrase "the object
Yes, even though the phrase is a little bit deceptive.
One should really say "the object currently referenced by
or "the object referred to by
a," or "the object
a points to,"
but usually people say "the object
a" and expect you to know what they mean.
The example program does very little that is visible on the monitor screen.
It would be nice to print something out.
The bytes that make up an object cannot be sent directly to the monitor because
they are not ASCII character data.
For example, the two
ints of a
Point use a data type that
can't be sent directly to a monitor.
Of course, the methods of an object are in Java bytecode, which makes no sense
to a monitor, either.
Luckily, there is a method defined in class
that can be used to create
String for a
toString() method of a
Point object creates a
String object, which can then be printed.
Look at the documentation:
public String toString(); // returns character data that can be printed | | | | | +--- this is the method name. It takes no parameters. | | | +--- this says that the method returns a String object | +--- anywhere you have a Point object, you can use this method
All objects have their own
toString() method, so it is possible to
print out something for any object your program has created.
(Often, though, the
String is not very useful.)
(Review: ) What is a parameter?