Hi Vicky
You have a very 'reasonable' doubt. The syntax to instantiate top-level nested classes and non-static inner classes is kind of inconsistent (this is my *personal* opinion and I maybe wrong).
Uma's explanation was perfect.
I have a comment on this statement by Krishna though:
how do you access 'a' above Outer.a right, so inner static class is no different, you need to call Outer.Inner, so to instantaite u'll say new Outer.Inner().
It's a matter of syntax and you cannot "intuitively" guess the expression to instantiate non-static inner classes by looking at the expression to instantiate top level nested classes.
Consider the following piece of code:
If we were to apply the same analogy here:
How do you access 'b' above: 'o.b' right? Then why couldn't you create the non-static inner class instance as
new o.InnerNonStatic()?
(Compiler will treat 'o' as a package name in the line 1 above since it won't be able to find a class 'o' in scope).
Thanks
Harwinder