// This program illustrates the scope of the identifier of a variable. // Barry Cornelius, 3 June 2000 public class VariableScope { public static void main(final String[] pArgs) { System.out.println("start of program"); int tCheck = 1; /*C*/ System.out.println("tCheck is: " + tCheck); /*C*/ if (tCheck==1) /*C*/ { /*C*/ System.out.println("start of then part"); /*C*/ int tValue = 42; /*T*/ /*C*/ System.out.println("tValue is: " + tValue); /*T*/ /*C*/ System.out.println("end of then part"); /*T*/ /*C*/ } /*C*/ else /*C*/ { /*C*/ System.out.println("start of else part"); /*C*/ int tValue = 27; /*E*/ /*C*/ System.out.println("tValue is: " + tValue); /*E*/ /*C*/ System.out.println("end of else part"); /*E*/ /*C*/ } /*C*/ System.out.println("after the if statement"); /*C*/ int tValue = 0; /*O*/ /*C*/ System.out.println("tValue is: " + tValue); /*O*/ /*C*/ System.out.println("end of program"); /*O*/ /*C*/ } }