Variables scope in Java
<pre><code>class Grade {
public static int f = 2;

public static void main(String[] args) {
    for (int f = 0; f &lt; 2; f++) {
        System.out.println(f);
    }
}
}
</code></pre>

<p>How does it happen, that "int f" overrides the static variable f? I thought that static int f is shared by the whole class and why does not the compiler give the error message that this variable is redefined? Why does it not become the duplicate of the static f? I thought that in java the scope blocks inherit the variables of their parent block.</p>
