More
about the 'dot' notation
Java uses the dot notation for
the sending of messages to other objects (and methods). For example, if
a method in a different class wants to send a message to invoke the method
printBalance()
for a particular object of class customer, we could write (assuming the
object is called aCustomer):
aCustomer.printBalance();
This means `send the message
printBalance() to the object aCustomer'.
This would, had we defined the Customer class appropriately, result in
the printBalance()
method being invoked for the object aCustomer.
The dot notation can also be
used to send messages to receive values of variables from objects. Thus
the statement:
aCustomer.familyName;
is a message that will result in the aCustomer
object returning the value of its familyName
variable (as long as this variable is public
?see later this unit).
Back
to top
RITSEC - Global Campus
Copyright © 1999 RITSEC- Middlesex
University. All rights reserved.
webmaster@globalcampus.com.eg
|