4, variable: In fact, is a storage space in memory, used to store constant data.
Function: Convenient for operation. Because some data is uncertain. So determine the noun and storage space for the data.
Features: Variable space can be reused.
When do I define a variable? as long as the data is uncertain, the variable is defined.
What are the necessary elements for the opening of variable spaces?
1, what data does this space store? The data type.
2, what's the name of this space? The variable name.
3, what is the first data for this space? The initialization value of the variable.
Scope and lifetime of variables :
Scope of the variable :
The scope starts at the position defined by the variable and ends with the curly brace where the variable is located;
Life cycle:
The variable is alive in memory starting at the defined position;
when a variable reaches its scope, it disappears in memory;
Java variables in-depth understanding