Java Reference
In-Depth Information
Both languages are not, strictly speaking, line oriented. They share the concept
of a statement that may span more than one line. Most statements in COBOL can
end with a period (.). In Java, all statements must end in a semicolon (;).
COBOL uses verbs such as IF, ELSE, and END-IF, both to test a condition and
to group statements that should be performed together as a result of that condition.
Java uses the first two verbs ( if and else ) to test conditions but uses the curly
braces ( {} ) to group conditional statements.
Finally, Java's syntax encourages the liberal use of objects in a program,
whereas performing COBOL subroutine calls and using the results properly can be
a little confusing. As a result, Java is much better suited to code-reuse strategies.
But let's not get ahead of ourselves. Instead, I'll start at the very beginning.
J AVA S TATEMENTS
A Java statement is the equivalent of a sentence in COBOL. A statement is the small-
est complete building block in a Java program. A statement can define a variable,
perform some logic, or define an interface. Every statement must end in a semicolon.
The simplest statement type is the sort that defines a variable. The syntax for
defining a variable is as follows:
I've already reviewed Java's access control options and the data types that are
available. I've also discussed how variables can be assigned initial values when they
are first instantiated.
An identifier is any named program component (such as variables, class names,
object names, or class members). Similar to a COBOL name, an identifier can be
made up from any alphanumeric characters but must start with an alphabetic char-
acter. There are a few differences, some as part of the language definition and some
that are simply conventions.
Java compilers are case sensitive. The identifier MsgSize is not the same as msgSize .
The dash (-) character is not valid in a variable name in many contexts and,
therefore, is never used in a Java identifier name. By convention, the under-
score (_) character is sometimes used to separate the parts of an identifier
name; mixed case can be used for the same purpose.
 
Search WWH ::




Custom Search