4.9 Statement
The first expression must be a field reference, array position reference, or a variable. The value of this variable, field, or array position will be changed to be the value of the evalauated expression on the right-hand side of =.
if (Expression) Statement else Statement
In this statement the expression should have a boolean type. It is evaluated first. If the expression evaluates to true, then the first statement (known as the then clause) is evaluated. If the expression evaluates to false, the statement following else (the else clause) is evaluated. Both statements may be blocks, including { }.
if (Expression) Statement
In this statement the expression should have a boolean type. It is evaluated first. If the expression evaluates to true, then the statement is evaluated; otherwise the statement has completed evaluation.
This form evaluates the expression, and then returns the value of the expression as the result of the method in which it is contained.
return ;
This form causes the method to cease evaluation, without producing a value. Should be used in conjunction with void for the MethodReturn.
This statement groups the sequence of statements together, commonly called a block. The statements evaluate sequentially.
while (Expression) {Statement ...}
Evaluates the expression, which must have type boolean. If the resulting value is true, then the statements are evaluated. After evaluating the statements, the expression is evaluated again. This repeats until the resulting value is false; once false, the statements are not evaluated and the while statement has completed evaluation.
do {Statement ...} while (expression)
The do statement evaluates the Statements, and then evaluates the expression, which must have type boolean. If the expression is true the statements evaluate again. This repeats until the expression is false, afterwhich the do statement has completed evaluation.
for (ForInit ForExpression ForUpdate ,...) {Statement ...}
The ForInit first initializes a variable, or evaluates a set of expressions. The variable can only be seen within the ForExpression, ForUpdate, and within the Statements. Then the ForExpression is evaluated, when true the Statements are evaluated. Subsequently, the ForUpdate evaluates a set of statement expressions or assignments before evaluating the expression again. Other than the ForInit stage, this repeats until the expression evaluates to false, afterwhich the for statement has completed evaluation.
Can only appear within the statement group of a while loop, do loop, or for loop. Causes the loop evaluation to complete without checking the expression again.
Can only appear within the statement group of a while loop, do loop, or for loop. Causes the statement group evaluation to complete, repeating to the evaluation of the conditional.
May only appear as the first statement of a constructor. Calls the constructor for the parent class using the given expressions as arguments. Expressions are evaluated left to right.
May only appear as the first statement of a constructor. Calls a different constructor from the same class, chosen by analyzing the given expressions.
Creates a local variable Id within a method body or a block statement; it is not visible outside the block or method, or to statements the preceed the declaration. The variable must be initialized prior to use.
Type Id = Expression ;
Creates a local variable Id within a method body or a block statement.
This set of expressions can be used in a statement position, provided they are followed by ’;’.