Inner classes defined inside a block like a method in Java can not have any modifiers not even public. Why?
<p>In Java, a class can <strong>never</strong> be qualified to be either private or protected. It can simply be <strong>public</strong> all the times. It's quite obvious, there is no question about it. </p>

<hr>

<p>Inner classes in Java however, can be designated with any of these modifiers private, protected or public. An inner class can also be defined within an individual block like a method. In such a case, an inner class can not be designated with any of these modifiers, private, public or protected.</p>

<hr>

<p>The following simple program is compiled with no errors and works just fine.</p>

<pre><code>package amazingjava;
final class Demo
{
    public class Really
    {
        public class Quite
        {
            public class Surprising
            {
                @Override
                public String toString()
                {
                    return( "it really works !" );
                }
            }
        }
    }
}

final public class Main
{
    public static void main(String[] args)
    {
        System.out.println( "It may be hard to believe, but " + new Demo().new   
        Really().new Quite().new Surprising().toString());

        class Really
        {
            class Quite
            {
                class Surprising
                {
                    @Override
                    public String toString()
                    {
                        return( "it really works !" );
                    }
                }
            }
        }
        System.out.println( "It may be hard to believe, but " + new Really().new 
       Quite().new Surprising().toString());
    }
}
</code></pre>

<p>It produces the following output.</p>

<p><em>It may be hard to believe, but it really works !</em></p>

<p><em>It may be hard to believe, but it really works !</em></p>

<hr>

<p>Now, my question is only that the inner classes declared inside the main() method in the above example can not have any modifiers. An  attempt to qualify those classes with any of modifiers private, protected or <strong>even public</strong> issues a compile time error! Why? Which default modifier is used by the compiler in such cases?</p>
