您的位置:寻梦网首页编程乐园Java天地Core JavaJava Lecture Notes
Introduction
Content
Apply
Reflect
Extend
previous.gif
 (3087 bytes)
next.gif
 (2959 bytes)

 
 
Content Index
Content Page # 23

Access to methods and variables

Sending messages to use methods from other classes

Inside a class, unless specified otherwise, messages (usually corresponding to method names) refer to the object of the class.

For an object to evoke some system behaviour not implemented as one of its methods, it must send a message to another object (or invoke a class method ?see later this unit).

To send a message, both the receiving object and the message to send need to be provided. This is achieved using the 'dot' notation, e.g.:

anObject.aMessage();
Every message must include an argument list in parentheses ( ... ), although there may not be any arguments, so the parentheses may be empty: ().

The sending of a message to an object results in a method of that object being invoked. invoked.

Back to top

basicline.gif (169 bytes)

RITSEC - Global Campus
Copyright © 1999 RITSEC- Middlesex University. All rights reserved.
webmaster@globalcampus.com.eg