| Variable Type |
Definition |
Initialization |
| Class (Field) |
Declared with the static keyword within a class or interface |
Created when the class or interface is prepared.
Automatically initialized to the default value of its type
Duration: as long as the class is loaded |
| Instance (Field) |
Declared within a class without the keyword static |
Created when a new instance is created
Automatically initialized to the default value of its type
Duration: for the life of the instance object
|
| Array components |
unnamed variables created when an array object is created
not when declared
|
intialized to the default value of the array type
Duration: until the array is no longer referenced |
| Method parameters |
named argument values passed to a method |
a new parameter variable is created each time the method is invoked
initialized with the corresponding argument value from the method call
Duration: method execution |
| Constructor parameters |
named argument values passed to the constructor |
a new parameter variable is created each time a new instance is created or the constructor is called
initialized to the corresponding argument value
Duration: construction execution |
| Exception-handling parameter |
variables in a catch clause |
a new exception-handling parameter is created each time an exception is caught by a catch clause
initialized with the actual object associated with the exception
Duration: catch clause execution |
| Local variables |
declared by local variable declarations |
a new local variable is created whenever flow of control enters a new block or for statement
initialized to whatever value is explicitly set within the block or for statement
Duration: execution of the block or for statement |