Home >Java >Javagetting Started >Similarities and differences between member variables and local variables
Similarities and differences between member variables and local variables:
Same points:
1. The format of defining variables is the same;
数据类型 变量名 = 变量值
(Video tutorial recommendation: java video tutorial)
2. They are declared first and then used;
3. Both have their corresponding scopes;
Differences:
1. The difference in the position of declaration between the two in the class;
Member variables are directly defined within a pair of { } in the class;
Local variables are declared within methods, method parameters, code blocks, constructor parameters, and inside constructors.
2. Local variables have no default initialization value.
Recommended tutorial: java entry program
The above is the detailed content of Similarities and differences between member variables and local variables. For more information, please follow other related articles on the PHP Chinese website!