Java Reference
In-Depth Information
6
Java Syntax
In This Chapter
COBOL vs. Java Syntax
Java Statements
Java Comments
Java Operators
Binary Arithmetic Operations
Understanding Reference Variables with COBOL
Exercises: Java's Syntax
Reviewing the Exercises
Until now, I have concentrated on the object-oriented concepts instead of the Java
syntax. I have already introduced some of Java's syntax by way of previous exam-
ples. This section will present a more complete definition of Java's syntax.
Java's syntax was deliberately based on C++, which was in turn based on C.
Therefore, COBOL programmers sometimes have a harder time understanding
Java's syntax than do C and C++ programmers. Harder is not the same as impos-
sible, however, so I expect you to follow along.
COBOL VS . J AVA S YNTAX
COBOL's syntax has the benefit of being very simple and somewhat like English. As
a result, COBOL programs tend to be longer than programs written in other lan-
guages but are often more readable. Significantly, COBOL programmers tend to be
pretty good typists.
In contrast, Java's syntax is much more concise. For example, a single state-
ment can contain many expressions. Another good example of this contrast is the
assignment function. In COBOL, the syntax is the wordy (but very clear) MOVE
xxx TO yyy. In Java, it is simply yyy = xxx.
149
Search WWH ::




Custom Search