up previous next contents
Next: if-else Up: Flow control and loops Previous: Objectives   Contents

Subsections

Statements and blocks

  • Two basic statements - expression statements, declaration statements.
  • Expression statements - such as i++ -have a semi-colon at the end.

Expressions that can be made into statements

  • Assignment: those that contain =
  • Prefix or postfix forms of ++ and -
  • Methods calls.
  • Object creation statements (new operator).

Declaration statements

  • Declare a variable and initialize it to a value.
  • Can appear anywhere inside a block.
  • Local variables exist only as long as the block containing their code is executing.
  • Braces group zero or more statements into a block.


up previous next contents
Next: if-else Up: Flow control and loops Previous: Objectives   Contents