A shadowed variable is temporarily unavailable since a variable with the same name has been declared in a more immediate scope. - Java Language Basics

Java examples for Language Basics:Variable

Description

A shadowed variable is temporarily unavailable since a variable with the same name has been declared in a more immediate scope.

Demo Code

public class Main
{
  static int x;

  public static void main(String[] args)
  {/*from   w  ww  .  ja  v  a  2 s . c  om*/
    x = 5;
    System.out.println("x = " + x);
    int x;
    System.out.println("x = " + x);
    x = 10;
    System.out.println("x = " + x);
    System.out.println("ShadowApp.x = " + Main.x);
  }

}

Related Tutorials