Java Variable Scope and Local Varibales

In this tutorial, you will learn about Variable Scope and Local variables in java programming language.

You will learn what is variable scope, how to create and use local variables, where they will be available, what is block scope, how variables declared in one scope are not available in another scope in detail with example.

Source code for this video tutorial


package methods;

public class Tutorial {
 public static void main(String[] args) {
  int age = 25;
  System.out.println(age);  
  {
   int mark = 20;
   System.out.println(mark);
   System.out.println(age);
   
  }
 }
 
 public static void display(){  
  //System.out.println(age);
 }
}