Variables in COBOL are either elementary or group items and
correspond loosely to primitive variables (such as integers,
characters, and real numbers) and objects in the Java programming language. COBOL is
not strongly typed like the Java programming language, however. In COBOL, you define a
"picture" of what can be stored in the variable whereas the Java programming language
requires a rigid type to be associated with that data storage
element. A "PIC" can be alphabetic (A),
alphanumeric (X), or numeric (9). The commonly used Java programming language primitives
are boolean, char, String, int,
and float.
COBOL uses level numbers on all data items:
- 01 is reserved for group names, which begin in area A
- elementary items begin in area B and use user-defined level values
You initialize items with a VALUE clause such as:
01 Result PIC 99 VALUE ZEROS.
In the Java programming language, there are no level numbers. You must explicitly label something
as a primitive or a class (similar to a "group") definition. You initialize
variables with an assignment operator:
int result = 0;
copyright 1996-2000 Magelang Institute dba jGuru