Let’s learn scope and lifetime of variables in java.
Scope and lifetime of variables in java
I have discussed variables in java in my earlier post. Now let’s learn the scope and lifetime of variables.
Local variable scope is within the block where it is declared and lifetime is until control exits the block in which local variable is declared.
Static variable scope is throughout the class and the lifetime is until the end of java program.
Also read – major features of java