3.17. Parameter Passing

Objects communicate by passing messages (see Section 1.4, p. 7). A message is implemented as a method call to invoke a particular method on an object. Static methods can be invoked on classes in Java. Parameters in the method call provide one way of exchanging information between the caller object and the callee object (which need not be different). Defining methods is discussed in Section 4.3.

The syntax of a method call can be any one of the following:

<object reference>.<method name> (<actual parameter list>)   <class name>.<static method name> (<actual parameter list>)   <method name> (<actual parameter list>)

The <object reference> must be an expression that evaluates to an object reference. If the caller and the ...

Get Programmer's Guide to Java™ Certification, A: A Comprehensive Primer, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.