Java Reference
In-Depth Information
accidental omission of the opening curly brace after the main( ) method causes the com-
piler to report the following two errors:
Clearly, the first error message is completely wrong because what is missing is not a semi-
colon, but a curly brace.
The point of this discussion is that when your program contains a syntax error, you
shouldn't necessarily take the compiler's messages at face value. The messages may be
misleading. You may need to “second-guess” an error message in order to find the real
problem. Also, look at the last few lines of code in your program that precede the line being
flagged. Sometimes an error will not be reported until several lines after the point at which
the error actually occurred.
A Second Simple Program
Perhaps no other construct is as important to a programming language as the assignment of
a value to a variable. A variable is a named memory location that can be assigned a value.
Further, the value of a variable can be changed during the execution of a program. That is,
the content of a variable is changeable, not fixed. The following program creates two vari-
ables called var1 and var2 :
Search WWH ::




Custom Search