Query about scope of variables in java
<pre><code>public class Knowing {

    static final long tooth = 343L;

    static long doIT(long tooth) {
        System.out.print(++tooth + " ");
        return ++tooth;
    }

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub

        System.out.print(tooth + " ");
        final long tooth = 340L;

        new Knowing().doIT(tooth);
        System.out.println(tooth);
    }
}
</code></pre>

<p>Okay so here is my question: </p>

<ul>
<li><p>If we have a global variable declared <code>static final long tooth = 343L;</code> How can we have another variable in the main method declared <code>final long tooth = 340L;</code> I just want to know why this is allowed because I ran it and there was no error?</p></li>
<li><p>And also shouldn't the access of the global static variable tooth be by using <em>className.variableName</em> and not by creating a new <em>instance.variable</em> name how come that is allowed with only a warning?</p></li>
</ul>
