Data Access, Properties, and Methods
- slide 19 : 29
Local variables in methods
Variables declared in the
statements
part - the block - of a method are called
local variables
Local variables:
May be declared anywhere in the block
Not necessarily in the initial part of the block
Can be initialized by an initializer
Can alternatively be declared without an initializer
No default value is assigned to a local variable
Different from instance and class variables which are given default values
The compiler will complain if a local variable is referred without prior assignment
Local variables and instance variables - initialization and default values.