type var = expr ;where type is a Java type name, var is a Java variable name, and expr is an expression of type compatible with the type of var. The assignment statement
int x = 5;asserts that ``the variable x has value 5''.
Java variable names and type names are identifiers consisting of any sequence of alphanumeric characters (letters, digits, and _) beginning with a letter or _ other than one of the following keywords:
Java is case-sensitive; the variable X is distinct from the variable x. There are three kinds of variables in Java: fields, method parameters, and local variables. Fields and method parameters are discussed in detail in the next subsection. We will defer a discussion of local variables until Section 1.11.1.abstract default if private throw boolean do implements protected throws break double import public transient byte else instanceof return try case extends int short void catch final interface static volatile char finally long super while class float native switch const for new synchronized continue goto package this
Java includes all of the basic statement forms found in the C programming language expressed in essentially the same syntax. In the remainder of this monograph, we will introduce these statement forms as they are needed. Although Java accepts most C syntax, many common C constructions are considered bad style in Java. For example, an assignment without the trailing semicolon is technically a valid expression in both C and Java. Common usage in C exploits this fact, embedding assignments as subexpressions of other expressions. In Java, this coding practice is considered very bad style and will not be mentioned again in this monograph.