

class blah {

    public int x1=10;

    public int x2=17;

    

    public String method1(double x1) {

        if (x1 > 0) { int x2 = 1; }

        { boolean x2 = true; }

        return method2(x1+x2);

    }



    public String method2(double x2) {

        return "the value: "+(x2+x1);

    }

}



public class TestScope {



    public static void main(String[] args) {

        System.out.println(new blah().method1(1));

    }

}



/*  After creating a new instance of class blah, method method1 of class =
blah

 *  is invoked with the argument 1.  The following is then tested:

 *  if( 1.0 > 0 ) { int x2 = 1 };

 *

 *  1.0 > 0 == true so int x2 = 1 is executed, but is scoped =
inside of the brackets so will 

 *  not affect the value of x2 outside of the braces. Next:

 *  { boolean x2 = true }

 *

 *  Again, x2 is scoped within the braces and is not visible outside of =
them.  Next, the

 *  return statement calls method two with the following argument:

 *  return metohd2(1.0 + 17.0)

 *

 *  in method2:

 *  return "the value: "+(18.0 + 10.0);

 *

 *  x2 has the value 18 since the value of x2 is gotten from the =
argument, and not from

 *  the field of class blah.  x1 has no other definition inside of =
method2 so its value must come 

 *  from the x1 field of class blah.

 *

 *  Output:

 *  the value: 28.0

 */