► |  | How to Design Classes Languages

1 | Professor J Beginner
2 | Professor J Intermediate
3 | Professor J Intermediate + Access
4 | Professor J Advanced
| Index

▼ | 2 | Professor J Intermediate

2.1 | import
2.2 | class
2.3 | interface
2.4 | Field
2.5 | Method
2.6 | Constructor
2.7 | Statement
2.8 | Expression

Version: 4.1.4
top← prev up next →

#### 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 ’;’.

}

top← prev up next →