Member variables:
Can be public,static, protected,default,final modified.
Local variables: Both in the method and in the code block (static and non-static)
Can be modified by default, final
Reference:
Baidu Search: Code blocks and member variables
Initializing static member variables in a static code block in Java
Share | 2015-12-31 22:18∮ old boy, | View 56 Reward: 5
Java
static{
Age = 2;
}
static int age = 4;
I put the statement of age statement behind the code block, why did not error, when the code block execution time should not be declared AH?
2015-12-31 22:28 User Acceptance
Static variables can only be defined inside a class, not defined in a static block or method can be defined inside a static variable within the class, initialization in a static block, because the inside of the class is not allowed to have an operation statement, such as JDBC operation, so can be in static block static{} initialization operation, For example, JDBC defines static variables primarily for external access, defines a local outside of which there is no access, why it is defined, and cannot define
The difference between a Java member variable and a local variable modifier