/* * This program demonstrates issues of scope */ public class LoopTest1 { public static void main(String[] args) { int x = 42; example(); System.out.println(x); // This is a different x from what's in example() // so it prints out 42 } public static void example() { int x = 3; for (int i = 1; i <= 10; i++) { System.out.println(x); } System.out.println(i); // i no longer exists here } // x ceases to exist here }