Java static scoping
<p>I have the following piece of code that is taken from a mock exam for Sun Certified Java Programmer:</p>

<pre><code>public class Static
{ 
      static 
      { 
            int x = 5; 
      }

      static int x,y; 
      public static void main(String args[]) 
      { 
            x--; myMethod(); 
            System.out.println(x + y + ++x); 
      }

      public static void myMethod() 
      { 
             y = x++ + ++x; 
      }
}
</code></pre>

<p>The test asks you for the result of this line:</p>

<pre><code>System.out.println(x + y + ++x);
</code></pre>

<p>The answer is 3, but I don't completely understand why it is 3. I can arrive at that answer if I completely ignore:</p>

<pre><code>      static 
      { 
            int x = 5; 
      }
</code></pre>

<p>My question is, what is the meaning of the above code snippet? Why does it not change the value of the variable 'x'?</p>
