The Java Program: Scope.java

  1 class Scope {
  2 
  3    static int first, second;
  4 
  5    static void pair (int second, int third) {
  6       Scope.first = second;
  7       Scope.second = third;
  8 
  9       /* local variable can shadow class variables */
 10       int first = second;    // LEGAL
 11 
 12       /*  local variables can't shadow formal parameters
 13       int second = second;  // ILLEGAL
 14       */
 15 
 16       int fourth = second;
 17       /*  local variables can't shadow other local variables
 18       int fourth = second;   // a second decl of "fourth" is ILLEGAL
 19       */
 20    }
 21 }