Summary 3 - Variables: Fields vs. Parameters vs. Local Variables
Summary 3 - Variables: Fields vs. Parameters vs. Local Variables
Local variables
What is this?
Type of Scope – where it is legal to refer Lifetime – when it is legal to refer to
Description
variable to the variable the variable
Associated with objects of the class in The lifetime of the object with which
Field The class in which it is defined
which the field is defined they are associated
Associated with a method; its value is given The body of the method for which it From when its method is called until the
Parameter
to its method when the method is called is a parameter time when its method is exited
Local From the point at which it is declared From the time it is declared to the time
Defined within a method
variable to the end of its enclosing block that its enclosing block is exited