Local Variable in Java | Core Java Tutorial

This Core Java Tutorials “Local Variable” post clearly explain what is local variable, declaration, accessing and compile time errors while working with local variables in java application.


 

Local variable:

  • Declaration of variable inside the Block or Method.
  • Local variable must be initialized before its use.
  • Local variables can be accessed directly.

 

Local variables can be accessed only within the block or method in which it has defined.

 

  • Local variables cannot be static.
  • Scope of local variable only within the block or method in which it has defined.
  • Static variables(global variable) available throughout the application.

 

Share this