Java Reference
In-Depth Information
3
Messages and Methods
In This Chapter
MYSUB COBOL
CALLER COBOL
Messages in Java
Multiple Messages
Method Overloading in COBOL
Terms to Review
Exercises: Classes, Objects, and Methods
Reviewing the Samples
HelloWorld: The Application
HelloWorld: The Applet
ErrorMsg: The Class
Let's return to the object-oriented concept discussion. You can extend the COBOL
example to explore some other Java concepts.
A subroutine call can be viewed as a message, passed from one object to another.
When you called MYSUB from CALLER, you prepared some information (in
TEXT-STRING) and asked MYSUB to evaluate it. In object-oriented (OO) terms,
this is sometimes referred to as message passing . That is, CALLER passed a particu-
lar type of message to MYSUB.
In Java, objects can send messages to other objects. In almost all respects, this
is similar to a subroutine call. However, objects typically support more than one
type of message. COBOL subroutines can do this, too, but it takes a little planning.
37
Search WWH ::




Custom Search