Scope of Variable in Java
Member Variables ( Class Level Scope )
When a variable in Java has a class level scope then it means that the variable can only be accessed inside the specific class. These variable should be declared outside any method of the class.
Local Variables ( Method Level Scope )
A variable is called to have a method level scope when it is only accessible inside any method and cannot be accessed outside that method.
Loop Variables (Block Scope)
A variable declared inside a block ( i.e. "{" and "}" ) is only accessible inside that block.

0 Comments