Java examples for Language Basics:Variable
A shadowed variable is temporarily unavailable since a variable with the same name has been declared in a more immediate scope.
public class Main { static int x; public static void main(String[] args) {//from ww w . java 2s. c o m 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); } }