Static classes in Java--something is being shadowed
<p>Following is the simplest example of <strong>static inner class</strong> in Java. Let's look at it.</p>

<pre><code>package staticclass;

final class Outer
{
    final public static class Inner
    {
        static String s = "Black";
    }

    static Extra Inner = new Extra();   //The inner class name and the object name of the class  Extra are same and it is responsible for shadowing/hiding Inner.s
}

final class Extra
{
    String s = "White";
}

final public class Main
{
    public static void main(String[] args)
    {
        System.out.println(Outer.Inner.s);
    }
}
</code></pre>

<hr>

<p>Within the <strong>Outer</strong> class, there is a static class named <strong>Inner</strong> and a static object with the same name <strong>Inner</strong> of type Extra. The program displays <strong>Whilte</strong> on the console, a string in the <strong>Extra</strong> class through <strong>Outer.Inner.s</strong> in main() which is intended to display the string contained in the <strong>Inner</strong> class within the <strong>Outer</strong> class</p>

<hr>

<p>Why is there no name collision between a static inner class and a static object of type Extra? How does the <strong>Extra</strong> class enjoys the higher priority than the <strong>Inner</strong> class and displays the string contained in the <strong>Extra</strong> class?</p>
