Java Reference
In-Depth Information
E
RROR
M
SG
C
LASS
This is the outline of a Java class definition:
public class ErrorMsg {
public String msgText;
public int msgSize;
...
// Some logic
...
}
The first line defines the class.
These next two lines declare the class instance data members, or properties.
These are associated with each instance of this class and can be of any valid type. In
many ways, they are analogous to the data items in MYSUB-CONTROL.
These two statements define the public data members for the class
ErrorMsg
.
The statements could be read this way: “The first data member is a
public
data
member, its type is
String
, and its name is
msgText
.” “The second data member is
a
public
data member, its type is
int
, and its name is
msgSize
.”
In order to use (or to call) this class, the consumer of this class (i.e., the caller)
creates a new instance of the class with the
new
operation. This is very similar in
concept to the COBOL example that defined several unique MYSUBx-CONTROL
areas in calling the COBOL program.