Scope, Operators, and Precedence

Scope of Variables

  • Inside a method, a block specified by curly braces defines a scope.
  • Variables can be declared in any block.
  • The scope of a variable determines its lifetime and its visibility.
  • A variable defined inside block is
    • Visible anywhere inside the block (including nested blocks).
    • Destroyed when program execution leaves the block.

Operators and Precedence

(  )
++ !
* / %
+
> < >= <=
== !=
&
|
?:
=

Order of Operations

  • When multiple operators are encountered that have the same precedence they are evaluated from left to right.

© 2017, Eric. All rights reserved.