2.7 Statement

  • 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 group of statements (known as the then clause) are evaluated. If the expression evaluates to false, the group of statements following else (the else clause) are evaluated.

  • return Expression ; 

    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.

  • {Statement ...}

    This statement groups the sequence of statements together, commonly called a block. The statements evaluate sequentially.

  • super (Expression ,...) ; 

    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.

  • Type Id ; 

    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.

  • StatementExpression ; 

    This set of expressions can be used in a statement position, provided they are followed by ’;’.