A COBOL program is divided up into four divisions:
- IDENTIFICATION DIVISION. Defines the name of the program
- ENVIRONMENT DIVISION. Defines computer-specific environment details
- DATA DIVISION. Defines variables, input/output formats, constants, and work areas
(storage space)
- PROCEDURE DIVISION. A group of procedures (paragraphs) that do the work of the program
COBOL programs explicitly separate the data and
procedures that operate on the data. Procedures are called
methods in the Java programming language.
Most COBOL statements are divided up into "area A" (four
characters wide starting from left edge) and "area B" (the
rest of the line). All this means is that the division, section,
paragraph, and 01 level data start in A and the executable statements
start in B. The Java programming language compiler has no such formatting restrictions that impart
meaning and ignores white space for the most part. Also, the Java programming language is
case-sensitive so that dog and Dog are totally
different names.
Java programs are organized by units that correspond to entities in
the real world: objects that encapsulate both the data and
the methods to manipulate that data. Objects with the same
characteristics and behavior are described by classes (storage
templates) and correspond roughly to COBOL groups. A Java program is
then primarily just a collection of class definitions such as:
class Vehicle {
...
}
class Car extends Vehicle {
...
}
class Truck extends Vehicle {
...
}
Program execution begins in the main() method of any of the classes
in your program; you specify which class when you launch the program.
copyright 1996-2000 Magelang Institute dba jGuru