A computer program is a compilation of instructions called statements. There are many types of statements in Java and some—such as if, while, for, and switch—are conditional statements that determine the program flow. This chapter discusses Java statements, starting with an overview and then providing details of each of them. The return statement, which is the statement to exit a method, is discussed in Chapter 4, “Objects and Classes.”
In programming, a statement is an instruction to do something. Statements control the sequence of program execution. Assigning a value to a variable is an example of a statement.
x = z + 5;
Even a variable declaration is a statement.
By contrast, an expression ...